title: Comparing strings to string produced by ifstream::getline
body: <p>I am working on a project where I need to read postscript and parse data from the file to use in my program. I am working on a function to test whether the postscript is valid by making sure it has opening and closing delimiters. </p>
  
  <p>Below is the segment of code I have written to accomplish this. I am confident that there are no additional spaces or anything of the sort in the postscript file to cause any discrepancy between delimitStr and lineStr. I also attempted to set delimitStr to "%%%BEGIN\0" and "%%%BEGIN", but the comparison never works.</p>
  
  <pre><code>string lineStr;
  bool beginFlag = false; //Switches to true when begin statement in postscript is found
  string delimitStr = "%%%BEGIN"; //Starts as opening  delimiter. Switches to closing when opening is found.
  while(psfile) {
      getline(psfile, lineStr);
      if(!beginFlag &amp;&amp; lineStr == delimitStr) {
          beginFlag = true;
          delimitStr = "%%%END";
          cerr &lt;&lt; "Begin found." &lt;&lt; endl;
      }
      else if(beginFlag &amp;&amp; lineStr == delimitStr)
          return true; //Only return true if file has beginning and ending delimiters.
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>