Don't set midline to true if we've reached the end of the input

Fixes issue #3