title: Ruby Types Error
body: <p>I'm trying to replace a column in a large (4.6GB) csv file with a value from another file.  For example:</p>
  
  <p>| id | name |</p>
  
  <p>| 01 |  john</p>
  
  <p>| id | address | phone |</p>
  
  <p>| 01 | place | number</p>
  
  <p>What I want is for 01 in the bottom table to be replaced with 'john'.</p>
  
  <pre><code>new = CSV.open("usage_new.csv", "w")
  prog = CSV.read("programs.csv", encoding:"ASCII-8BIT")
  
  CSV.foreach("Usage-fixed.csv", encoding:"ASCII-8BIT") do |row|
      for i in 0..prog.size
          if row[5] == prog[i][0]
              puts row[5] + " equals " + prog[i][1]
              new &lt;&lt; [ row[0] + row[1] + row[2] + row[3] + row[4] + prog[i][1] + row[5] + row[6] + row[7] + row[8] + row[9] + row[10] + row[11] + row[12] + row[13] + row[14] + row[15] + row[16] + row[17] ]
          end
      end
  end
  </code></pre>
  
  <p>The problem is i keep getting the following error:</p>
  
  <pre><code>blah.rb:11:in `block (2 levels) in &lt;main&gt;': undefined method `[]' for nil:NilClass (NoMethodError)
      from blah.rb:10:in `each'
      from blah.rb:10:in `block in &lt;main&gt;'
      from /home/mastelj/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/csv.rb:1717:in `each'
      from /home/mastelj/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/csv.rb:1120:in `block in foreach'
      from /home/mastelj/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/csv.rb:1266:in `open'
      from /home/mastelj/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/csv.rb:1119:in `foreach'
      from blah.rb:9:in `&lt;main&gt;'
  </code></pre>
  
  <p>Any ideas on what might cause something like this?</p>
  
  <p>Edit: Line 11 (the offending line) is the line with the iff statement</p>