Added error checking for the file to be read.