fixed tiny error checking bug when attempting to open a file