title: ofstream: running index doesn't work
body: <p>I want to write several lines to a file. Each line has an index (running index).
  My code is:</p>
  
  <pre><code>ofstream outputFile;
  int index = 0;
  
  outputFile &lt;&lt; ++index &lt;&lt; ") FirstLine" &lt;&lt;endl
             &lt;&lt; ++index &lt;&lt; ") SecondLine" &lt;&lt;endl
             ...
             &lt;&lt; ++index &lt;&lt; ") LastLine" &lt;&lt;endl;
  </code></pre>
  
  <p>Problem is that I get no running index. That is, all lines has the same index (which is the total lines number). So my questions are firstly, how does ofstream work (meaning why do I get the described result). Secondly, what should I do to get it work?</p>