title: how to use erb to output file after binding
body: <p>I got the following example:</p>
  
  <pre><code>require 'erb' 
  
  names = []
  names.push( { 'first' =&gt; "Jack", 'last' =&gt; "Herrington" } )
  names.push( { 'first' =&gt; "LoriLi", 'last' =&gt; "Herrington" } )
  names.push( { 'first' =&gt; "Megan", 'last' =&gt; "Herrington" } )
  
  myname = "John Smith"
  
  File.open( ARGV[0] ) { |fh|
  
  erb = ERB.new( fh.read )
  print erb.result( binding )
  </code></pre>
  
  <p>accompanied by</p>
  
  <pre><code>text.txt
  &lt;% name = "Jack" %&gt;
  Hello &lt;%= name %&gt;
  
  
  &lt;% names.each { |name| %&gt;
  Hello &lt;%= name[ 'first' ] %&gt; &lt;%= name[ 'last' ] %&gt;
  &lt;% } %&gt;
  
  hi, my name is &lt;%= myname %&gt;
  
  }
  </code></pre>
  
  <p>it prints nicely to screen.</p>
  
  <p>what is the simplest way to output to another file: "text2.txt" instead of to the screen?</p>
  
  <p>I know this is really a piece of cake for most of you experienced ruby masters, but for me who just picked up a Beginning Ruby from Novice...it's challenging now...but I want to use the code for real life purpose...</p>
  
  <p>thank you!!!</p>