title: Using the getline()
body: <p>hi there can someone explain to me why are these two programs different?</p>
  
  <pre><code>int main (){
      string line;
      while (getline(cin,line)){
          cout &lt;&lt; line;
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>int main (){
      string line;
      while (getline(cin,line)){
          cout &lt;&lt; line &lt;&lt; endl;
      }
  }
  </code></pre>
  
  <p>It seems like the second program prints everything out while the first program will only print the last line for some reason. I'm working on an assignment grabbing lines from a file with IO redirection but when I want to print the lines out I'm forced to print a newline character to get all the lines out. </p>