Uploading file inruby on rails

I am uploading on html file and saving in public folder for this i am
writing this code
  def self.save(upload)
    name = upload['datafile'].original_filename
    directory = "public/uploads"
    path = File.join(directory, name)
    str ="Hi9 How r u "
    File.open(path, "a") { |f| f.puts str }
    return name
  end
what this is doing means i am inserting str into that file
it is over writing the existing file content
i dont want to overwrite , i want to add in the last line of the
document
please help me on this

Sujith Gangaraju wrote:

I am uploading on html file and saving in public folder for this i am
writing this code
  def self.save(upload)
    name = upload['datafile'].original_filename
    directory = "public/uploads"
    path = File.join(directory, name)
    str ="Hi9 How r u "
    File.open(path, "a") { |f| f.puts str }
    return name
  end
what this is doing means i am inserting str into that file
it is over writing the existing file content
i dont want to overwrite , i want to add in the last line of the
document
please help me on this

Try once more sujith............
Come onnnnnn....
you can do ittttttt................