title: How do I add an extension to a file when downloading it?
body: <p>This magical Ruby script downloads a couple of XML files from a website, but the files don't have an extension. I'd like to add the prefix <code>.xml</code> to every file it downloads.</p>
  
  <p>This is where I am right now and it won't work: </p>
  
  <pre><code>require 'rubygems'
  require 'nokogiri'
  require 'open-uri'
  
  URL = 'localhost'
  extension = '.xml'
  
  Nokogiri::HTML(open(URL)).xpath("//a/@href").each do |src|
    src = File.join(extension).last
    File.open(File.basename(src),'wb') do |f| 
      f.write(open(src).read)
    end
    puts "Done with: #{URL}"
  end
  </code></pre>
  
  <p>Any ideas on how to make this work? </p>