title: How do you pull data from external files, and then use it? i.e. Visit The 5 URLs in url.txt
body: <p>I want to visit every URL listed on a text file.</p>
  
  <p>I have:</p>
  
  <pre><code>require 'mechanize'
  
  File.open('sources.txt').each_line { |url|
    agent = Mechanize.new
    puts "Visiting #{url}"
    mypage = agent.get("#{url}")
    current_url = mypage.uri.to_s
    puts "The final URL is #{current_url}"
  }
  </code></pre>
  
  <p>This code runs through the URLs in <code>sources.txt</code>, tells you it's doing so, then tells you the URL once it reaches the page. i.e. if <code>www.foo.com</code> is in the <code>source.txt</code>, but <code>www.foo.com</code> resolves to just <code>foo.com</code> (no WWW), it will tell you so. </p>
  
  <p>How can I save EACH resolved/final/current URL into a single, line separated text file? </p>