title: Read "n" number of lines from a file C++
body: <p>Quick question, </p>
  
  <p>Assuming that you were told to read input, only 10 lines, from a text file; nevertheless, the text file has 40 lines. Would it be bad programming to do the following:</p>
  
  <pre><code>while ( infile &gt;&gt; input &amp;&amp; num_lines &lt; 10 ) {
        do whatever...
        num_lines++;
  }
  // closed file
  infile.close();
  </code></pre>
  
  <p>Is there a better way to do this?? </p>
  
  <p>I should have mentioned that when i said "lines" i merely meant the following:</p>
  
  <pre><code>planet
  tomorrow
  car
  etc
  </code></pre>
  
  <p>So yes, to read a line of text, get line function should be implemented  </p>