A time-worthy way to do this is to read the line.
Now the last char should be \n . Separate it. Then look at the previous character. It will be either \r or something else. If it is \r , separate it.
There are no other features in Windows [ascii] text files.
This works even if the file is mixed (for example, some lines \r\n , and some only \n ).
You can pre-do this on a few lines, just to make sure that you are not dealing with something strange.
After that, you now know what to expect from most of the file. But the strip method is an overall reliable way. On Windows, you can import a file from Unix (or vice versa).
Craig estey
source share