Why is this not reversing the numbers in my vector when they get copied to my file?
<p>The program runs perfectly, and the numbers of my vector end up in my file, but they're not reversed. </p>

<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;fstream&gt;
using namespace std;

void reversevector(vector&lt;double&gt; &amp;vd, int i, int j)
{
    if(i&gt;=j) {
        double temp = vd[i];
        vd[i]=vd[j];
        vd[j]=temp;
        i++;
        j--;
    }
}
int main() {
    double n = 0;
    vector&lt;double&gt; vd;
    while (cin&gt;&gt;n) {
        vd.push_back(n);
    }

    reversevector(vd,0,vd.size()-1);

    ofstream ofs("reversedlist.txt");

    if(!ofs) {
        cout&lt;&lt;"error";
        exit(1);
    }

    for(int i=0; i&lt;vd.size(); i++){
        ofs&lt;&lt;vd[i];
    }

    ofs.close();
}
</code></pre>

<p>For example: If I put 12345 into my vector, it should print out 54321 into my file. When I open my file, it still contains 12345.</p>
