Added extra checks for end-of-line.
Fixed error reporting buffer overflow.