Added error checking for the input file.