check that file exists before trying to read it