functions that check if a file exists in a directory