(#647) Fix newline handling in Vty.

@Fuuzetsu @ethercrow sorry for the confusion with the previous PR, it definitely wasn't ready but I didn't really intend to delete the branch.

I think this comes quite a ways toward fixing #647. I probably won't have time to write unit tests in the next week, don't know if you care about that.