title: String vectors not working as expected with newline and iterators? (C++)
body: <p>I have a text file made of 3 lines:</p>
  
  <pre><code>Line 1
  
  Line 3
  </code></pre>
  
  <p>(Line 1, a blank line, and Line 3)</p>
  
  <pre><code>vector&lt;string&gt; text;
  vector&lt;string&gt;::iterator it;
  ifstream file("test.txt");
  string str;
  
  while (getline(file, str))
  {
    if (str.length() == 0)
      str = "\n";
    // since getline discards the newline character, replacing blank strings with newline
  
    text.push_back(str);
  } // while
  
  for (it=text.begin(); it &lt; text.end(); it++) 
    cout &lt;&lt; (*it);
  </code></pre>
  
  <p>Prints out:</p>
  
  <pre><code>Line 1
  Line 3
  </code></pre>
  
  <p>I'm not sure why the string with only a newline was not printed out. Any help would be appreciated. Thanks.</p>