fix lines function to handle \r as a newline