title: not able to read a file with getline() properly
body: <p>I have read many posts but whatever i do, i cant get rid of the problem.
  My input file is like below</p>
  
  <blockquote>
  <pre><code>getData
  getData,value1,value2
  </code></pre>
  </blockquote>
  
  <pre><code>string value, line;
  while (getline(inFile, line)) {
  line.erase(std::remove(line.begin(), line.end(), '\r'), line.end());
  stringstream linestream(line);
  getline(linestream, value, ',');
  Logging::PrintInfo("Got Request3 %s.\n",value.c_str());
  }
  </code></pre>
  
  <p>I get the print as </p>
  
  <blockquote>
  <pre><code>Got Request3 getData --&gt; first loop
  Got Request3 ta  --&gt;second loop.
  </code></pre>
  </blockquote>
  
  <p>The initial characters are being cut from the string. </p>
  
  <p>I have tried the below also for trimming the \r, but still the problem exists.</p>
  
  <pre><code>if ( line.size() &amp;&amp; line[line.size()-1] == '\r' ) {
              //line1 = line.substr( 0, line.size() - 1 );}
  
          line.erase(0, line.find_first_not_of("\r"));
          line.erase(line.find_last_not_of("\r")+1);
  </code></pre>
  
  <p>Tried doing  </p>
  
  <pre><code>    line.erase(std::remove(line.begin(), line.end(), '\r'), line.end());
      line.erase(std::remove(line.begin(), line.end(), '\n'), line.end());
      line.erase(std::remove(line.begin(), line.end(), '\t'), line.end());
      line.erase(std::remove(line.begin(), line.end(), '\f'), line.end());
      line.erase(std::remove(line.begin(), line.end(), '\v'), line.end());
      line.erase(line.begin(), std::find_if(line.begin(), line.end(), std::bind1st(std::not_equal_to&lt;char&gt;(), ' ')));
      line.erase(std::find_if(line.rbegin(), line.rend(), std::bind1st(std::not_equal_to&lt;char&gt;(), ' ')).base(), line.end());
  </code></pre>
  
  <p>But my issue is not resolved. First few characters are still lost. After multiple tries I found that the issue is with \r. But I still have a problem.</p>
  
  <p>As soon as I remove the \r, my next line string gets cut. But if I do not cut it, my first line has a \r and that's not being processed.</p>