Strange YAML Problem: Sometimes can't open file

This is a weird problem that only happens once in a while. Most of the
time there is no problem, but occassionally, I cannot open a file.
Here's some of the code.

############# ACTION 1 #########################
require 'fastercsv'
require 'tmpdir'
require 'yaml'
# blah blah
#blah

@parsed_file = FasterCSV.parse(params[:dump][:file])
# blah
@temp_file = Tempfile.new("temporary_csv_file")
@temp_file.write(YAML::dump(@parsed_file))
@temp_file.close
################################################

In the view, there is a button to import the file after it has been
checked.
############ VIEW 1 ###########
<%= button_to "Import Data", :action => :import_data, :path =>
@temp_file.path %>
######################

######### ACTION "IMPORT DATA" ##########
require 'yaml'
begin
@csv_file = YAML::load(File.open(params[:path]))
rescue
flash[:error] = "Could not import links; error opening temporary
file."
redirect_to :action => :upload and return
end
###########################

Most of the time, there is no problem opening the file. But sometimes,
the file fails to open. It's weird because it only happens sometimes;
does anyone have any suggestions on this?

Same file randomly works? Or are the files slightly different? Trap the error and spit it out instead of hiding it in the rescue. That might help figure out the cause...

Might be a UTF8 garbled-character issue. Maybe it's not a valid CSV, maybe it's unterminated...

-philip

Same file randomly works? Or are the files slightly different? Trap
the error and spit it out instead of hiding it in the rescue. That
might help figure out the cause...

Might be a UTF8 garbled-character issue. Maybe it's not a valid CSV,
maybe it's unterminated...

-philip

It can be the same file each time. Very weird. Here is the error it
catches:

rescued #<Errno::ENOENT: No such file or directory -
/var/folders/kp/kppgyL-IHt03oEOrzn+sBk+++TM/-Tmp-/temporary_csv_file.680.0>

And here is the path of a working one:
"/var/folders/kp/kppgyL-IHt03oEOrzn+sBk+++TM/-Tmp-/temporary_csv_file.680.0"

Is this just a bug with YAML?