added error checking while parsing the file