title: How can I know if a text file ends with carriage return or not?
body: <p>I have to process a text file and check if it ends with a carriage return or not. </p>
  
  <p>I have to read to whole content, make some changes and re-write it into the target file, keeping exactly the same formatting as original. And here is the problem: I don't know if the original file contains a line break or not at the end.</p>
  
  <p>I've already tried:</p>
  
  <ul>
  <li>the StreamReader.ReadLine() method, but the string that is returned does not contain the terminating carriage return and/or line feed.</li>
  <li>also the ReadToEnd() method can be a solution, but I'm wondering about the performance in case of very big files. The solution has to be efficient. </li>
  <li>getting the last 2 characters and check if them are equal to "\r\n" may resolve it, but I have to deal with lots of encodings, and it seems practically impossible to get them.</li>
  </ul>
  
  <p>How can I efficiently read all the text of a file and determine whether it ended in a newline?</p>