Add explicit check to make sure that temp_file is an existing file