Added an additional check for reading from a file.