title: how to use eof in a for loop with iterating integer c++
body: <p>this gives me a segmentation fault:</p>
  
  <pre><code>for (int i=0; !file.eof();i++)
  {
    getline(file,line);
    roughInput.lines[i].split(line);
  }
  </code></pre>
  
  <p>and this doesn't</p>
  
  <pre><code>for (int i=0; i&lt;2;i++)
  {
    getline(file,line);
    roughInput.lines[i].split(line);
  }
  </code></pre>
  
  <p>from my understanding for should increase i by one until the end of file, right?
  since i couldn't find much example on i-net, is there a better solution?</p>