Add line clearing

This is WIP, since there's a bug that causes the code to split newlines into
different result objects. The tests fail, so you can see the bugs in the test
result.

Any suggestions on how to fix the bug?