title: C++ - while(getline) doesn't get the first line of file
body: <p>I've been working on a C++ program where I read a files contents and copy then onto another file but it always seem to skip the first line. I've seen others having trouble with this and they used these lines of code:</p>
  
  <pre><code>file.clear();
  file.seekg(0);
  </code></pre>
  
  <p>to reset the position but its not working for me. I've tried it in multiple spots but still no luck. Any ideas? Heres my code.</p>
  
  <pre><code>ofstream write("Mar 23 2013.txt");
  
  for(int x = 1; x &lt;= 50; x++){
  
      stringstream ss;
      ss &lt;&lt; "MAR23_" &lt;&lt; x;
  
      ifstream file(ss.str().c_str());
  
      if(!file.is_open())
          cout &lt;&lt; ss.str() &lt;&lt; " could not be opened/found." &lt;&lt; endl;
      else{  
  
          while(getline(file,line)){
  
              file &gt;&gt; time &gt;&gt; ch &gt;&gt; sensor1 &gt;&gt; ch &gt;&gt; temp &gt;&gt; ch &gt;&gt; 
                      sensor2 &gt;&gt; ch &gt;&gt; sensor3;
  
              file.ignore(numeric_limits&lt;streamsize&gt;::max(), '\n');
  
              //output = convertEpoch(time);
  
              write &lt;&lt; time &lt;&lt; "  Temperature:" &lt;&lt; temp &lt;&lt; "ºF  S1:" &lt;&lt;
                          sensor1 &lt;&lt; "  S2:" &lt;&lt; sensor2 &lt;&lt; "  S3:" &lt;&lt; 
                          sensor3 &lt;&lt; endl;
  
          }
          file.close();
      }  
  }
  
  write.close();
  
  return 0;
  </code></pre>