Fix handling of line endings at right side of screen