title: Using getline and istringstream to read from file is producing zeroes
body: <p>I have a text file that looks like so:</p>
  
  <pre><code>6
  1 2 3 4 5 6
  1 2
  1 4
  1 5
  2 3
  2 5
  2 6
  3 4
  3 6
  4 5
  5 6
  </code></pre>
  
  <p>I use the following to read the lines of the file in to my variables and arrays:</p>
  
  <pre><code>//Read first line
  if( std::getline(in, line))                                                                                                                                                                                                              
      {                                                                                                                                                                                                                                        
          std::istringstream iss(line);                                                                                                                                                                                                        
          while( iss &gt;&gt; a);                                                                                                                                                                                                           
      }                                                                                                                                                                                                                                        
  
      // read second line                                                                                                                                                                                                 
      int i = 0;                                                                                                                                                                                                                               
      if( std::getline(in, line) )                                                                                                                                                                                                             
      {                                                                                                                                                                                                                                        
          std::istringstream iss(line);                                                                                                                                                                                                        
          while( iss &gt;&gt; b[i] )                                                                                                                                                                                                          
          {                                                                                                                                                                                                                                    
              ++i;                                                                                                                                                                                                                             
          }                                                                                                                                                                                                                                    
      }                                                                                                                                                                                                                                        
  
      // read rest of file matrix                                                                                                                                                                               
      int x = 0;                                                                                                                                                                                                                               
      while( !in.eof())                                                                                                                                                                                                                        
      {                                                                                                                                                                                                                                        
          if( std::getline(in, line))                                                                                                                                                                                                          
          {                                                                                                                                                                                                                                    
              std::istringstream iss1(line);                                                                                                                                                                                                   
              while( iss1 &gt;&gt; c[x])                                                                                                                                                                                                         
              {                                                                                                                                                                                                                                
                  ++x;                                                                                                                                                                                                                         
              }                                                                                                                                                                                                                                
          }                                                                                                                                                                                                                                    
      }     
  </code></pre>
  
  <p>In the code above <code>a</code> is an int, <code>b</code> and <code>c</code> are int arrays, <code>in</code> is an istream operator and <code>line</code> is a <code>std::string</code>. It seems to work fine however when I <code>std::cout</code> the variable and arrays I get the following:</p>
  
  <pre><code>6
  1,2,3,4,5,6
  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  </code></pre>
  
  <p>For some reason array <code>c</code> seems to be filled with all zeroes instead of the data from the file. This is odd to me since I am reading the first two lines exactly the same way and they seemed to read in just fine. Any ideas?</p>