fixed bug in checking for file existence