title: read from a file while another process is writing to it using std::fstream
body: <p>I need to read from a file line by line, it's done by std::getline. The problem another process is appending data to it all the time, then I need to read the new lines. </p>
  
  <p>For example, the file contains 10 lines at first, my program read the 10 line, then my program should wait. A while later another process append 5 lines to the file, then my program read the 5 lines.</p>
  
  <p>I tried this but it doesn't work:</p>
  
  <pre><code>int main() {
      ifstream ifs("test.txt");
  
      string line;
      while(1) {
          while(std::getline(ifs, line)) {
              cout &lt;&lt; line &lt;&lt; endl;
          }
          Sleep(50);
      }
  }
  </code></pre>
  
  <p>Any idea? Thanks.</p>