check that the file exists first, before doing anything with it