title: std::getline throwing when it hits eof
body: <p><code>std::getline</code> throws exception when it gets an <code>eof</code>. 
  this is how I am doing.</p>
  
  <pre><code>std::ifstream stream;
  stream.exceptions(std::ifstream::failbit|std::ifstream::badbit);
  try{
    stream.open(_file.c_str(), std::ios_base::in);
  }catch(std::ifstream::failure e){
    std::cout &lt;&lt; "Failed to open file " &lt;&lt; _file.c_str() &lt;&lt; " for reading" &lt;&lt; std::endl;
  }
  while(!stream.eof()){
    std::string buffer = "";
    std::getline(stream, buffer);
    //process buffer
    //I do also need to maintain state while parsing
  }
  </code></pre>
  
  <p>In the above code <code>getline</code> is throwing exception as it gets <code>eof</code> 
  How to handle this situation ?</p>
  
  <h2>EDIT</h2>
  
  <pre><code>std::string buffer = "";
  while(std::getline(stream, buffer)){
      //also causes getline to hit eof and throw
  }
  </code></pre>