Fix line splitting logic.

The current line splitting logic is broken, crashes the I/O thread and blocks the whole redshift process.

(The change on line 292 is not technically necessary, but more clearly communicates what is happening.)