Yes, if the file is known to contain only one style or if the program isn't supposed to handle malformed files.
Correct.
But think about it:
You create a new textfile on e.g. Winbloze (CRLF).
Windows itself "inserts" the LineEndings at the end of a string each time you hit return. There will be no single CR or single LF in that File, except if you manipulate those strings from some own code
Bottom Line: You have a 99.9999% Chance there will be only one style of LineEndings in a Textfile, but this depends entirely on the OS the TextFile is created on
and as i said: Your code isn't that bad.
It just bugged me, that you run FORWARD through the whole text without breaking after first HIT
If it's a really, really, really big textfile:
If you have enough RAM: Load the whole Textfile in one go
If not, read the first XX KB/MB
In both cases: Start at the end and look for the first hit on the LineEndings.
You have a 99.99999% Chance it's the LineEnding the File was created with