Fix and test for "panic: runtime error: index out of range for..." caused by lines that contain just a \n

Fix for empty lines with just a newline which caused a panic in `line[len(line)-1]`. Added a test that tries a newline. Sorry for the extra changes due to `go fmt`.

Ben