Added extra checks in the parser for invalid line.
Credits to xasuma for the report.