title: How to read from a file line by line?
body: <p>I have a problem. I want to read each line from 'lol.txt'. What I have so far doesn't seem to work. Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main()
  {
  ofstream file("lel.txt", ios::app);
  ifstream file2("lol.txt");
  
  //string write;
  //getline(cin, write);
  //file &lt;&lt; write &lt;&lt; "\n";
  //file.close();
  //}
  
  string;
  file2 &gt;&gt; read;
  getline(cin, read);
  cout &lt;&lt; read;
  }
  </code></pre>
  
  <p>Thanks!</p>
  
  <p>P.S.: I am using Ubuntu and Code::Blocks.</p>