Handle carriage returns in lines()

Closes #305 #335