title: Getline to String Copies newline as well
body: <p>I am reading a file line by line and adding each line to a string. However the string length increases by 1 for every line which I believe is due to newline character. How can I remove it from being copied. </p>
  
  <p>Here is my code attempt to do the same. </p>
  
  <pre><code>if (inputFile.is_open())
  {
      {
          string currentLine;
          while (!inputFile.eof())
              while( getline( inputFile, currentLine ) )
              {
                  string s1=currentLine;
                  cout&lt;&lt;s1.length();
              }
  </code></pre>
  
  <p>[Updated Description] i have used notepad++ to determine the length of what i am selecting line by line. So they are showing some 123, 450, 500, 120 for which my program shows 124,451,501,120. Except for the last line, all line.length() shows an increased by 1 value.</p>