title: File pointer movement for getline
body: <p>I have got an input file with following data</p>
  
  <pre><code>2
  100
  2
  10 90
  150
  3
  70 10 80
  </code></pre>
  
  <p>Now, I am able to read till 4th line ( 10 90) but when reading 5th line(150), the file pointer seems to be stuck at 4th line. I have tried infile.clear() just incase. How do I make sure that file pointer is moving correctly or position it at next line? Appreciate your feedback.</p>
  
  <p>-Amit</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  
  using namespace std;
  
  int main(void) {
  
  int cases;
  int total_credit=0;
  int list_size=0;
  string list_price;
  
  
  //Read file "filename".
  
  ifstream infile;
  infile.open("A-large-practice.in",ifstream::in);
  if(!infile.is_open()) {
      cout &lt;&lt; "\n The file cannot be opened" &lt;&lt; endl;
      return 1;
  }
  
  else {
      cout&lt;&lt;"Reading from the file"&lt;&lt;endl;
      infile &gt;&gt; cases;       
      cout &lt;&lt; "Total Cases = " &lt;&lt; cases &lt;&lt; endl;
      int j=0;
  
      while (infile.good() &amp;&amp; j &lt; cases) {
  
          total_credit=0;
          list_size=0;
  
          infile &gt;&gt; total_credit;
          infile &gt;&gt; list_size;
  
          cout &lt;&lt; "Total Credit = " &lt;&lt; total_credit &lt;&lt; endl;
          cout &lt;&lt; "List Size = " &lt;&lt; list_size &lt;&lt; endl;
          //cout &lt;&lt; "Sum of total_credit and list_size" &lt;&lt; sum_test &lt;&lt; endl; 
  
          int array[list_size];
          int i =0;
          while(i &lt; list_size) {
              istringstream stream1;  
              string s;
              getline(infile,s,' ');
              stream1.str(s);
              stream1 &gt;&gt; array[i];
              //cout &lt;&lt; "Here's what in file = " &lt;&lt; s &lt;&lt;endl;
              //array[i]=s;
              i++;
          }
  
          cout &lt;&lt; "List Price = " &lt;&lt; array[0] &lt;&lt; " Next = " &lt;&lt; array[1] &lt;&lt; endl;          
          int sum = array[0] + array[1];
          cout &lt;&lt; "Sum Total = " &lt;&lt; sum &lt;&lt; endl;
          cout &lt;&lt;"Testing" &lt;&lt; endl;   
          j++;    
      }       
  }   
  return 0;   
  
  }
  </code></pre>