Fixed check_file_exists function