title: file size c is different than the size data string's size
body: <p>I have a file I'm writing to and then changing the size of it to the size of text written to it something like:</p>
  
  <pre><code>FILE * file...
  </code></pre>
  
  <p>I get all the data from the file and change the file's size to the data's size but it differs. The string's size is smaller then the filelength and it cuts it and loses data.
  What might be the problem?</p>
  
  <pre><code>while(fgets(cLine, sizeof(cLine), file) )
      str.append((string)cLine);
  fputs(str.c_str(),file);
  _chsize( fileno(file), (int)str.size() );
  </code></pre>
  
  <p>When I checked it always <code>fileLength(fileno(file))</code> is larger than <code>str.size()</code>!</p>