Comments end when the input ends or a newline occurs

This fixes #382, which occured because the REPL doesn't use trailing newlines.
Add regression test for #382
Merge pull request #411 from olasd/bugfix/382

Fix handling of comments at end of input