As described in the TODO, "we should probably detect \r and do something about it. Just ignoring it isn't the right answer, though."
I modified the code to first check for a \r and if it finds it, remove it from the string. If there is no \r, it then just checks for \n and removes that, else it throws the error.
This helps handle both \r\n and \n terminated files while parsing