Fix issue #1

The ProcessLine function was really weak against arbitrary input. There
still some work to do, but now it works with the expected cases, plus
some exotic ones.