title: read last line in c++
body: <p>for some reason, my program doesn't print the last line of a textfile if the last line contains less characters than the buffer</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;fstream&gt;
  
  int main()
  {
      std::ifstream read("test.txt");
      char buffer[12];
  
      while(!read.eof())
      {
          read.getline(buffer,11);
          if(!read.eof())
              std::cout&lt;&lt;buffer&lt;&lt;'\n';
          read.clear();
  
      }
      read.close();
  
      return 0;
  }
  </code></pre>