better parsing for line endings