title: Ruby undefined method `[]' for nil:NilClass (NoMethodError) error
body: <p>I'm trying to figure out why I keep getting the following error:
  <a href="https://i.stack.imgur.com/Nikh2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Nikh2.png" alt="enter image description here"></a></p>
  
  <p>From the following code:</p>
  
  <pre><code>def information_transfer()
    file_contents = CSV.read("test.csv", col_sep: ",", encoding: "ISO8859-1")
    file_contents2 = CSV.read("applicantinfo.csv", col_sep: ",", encoding:"ISO8859-1")
    arraysize = file_contents.length
    arraysize1 = file_contents2.length
    for i in 1..arraysize
      for x in 1..arraysize1
        if file_contents[i][0] == file_contents2[x][0]
          CSV.open("language_output.csv", "wb") do |csv|
            csv &lt;&lt; [file_contents[i][0], file_contents[i][1], file_contents[i][2],file_contents[i][3], file_contents[i][4], 
            file_contents[i][5], file_contents[i][6], file_contents[i][7], file_contents[i][8],file_contents[i][9], 
            file_contents[i][10], file_contents[i][11], file_contents[i][12], file_contents[i][13], file_contents[i][14],
            file_contents[i][15], file_contents[i][16], file_contents[i][17], file_contents[i][18], file_contents2[i][24],file_contents2[i][25], 
            file_contents2[i][26],file_contents2[i][27], file_contents2[i][28], file_contents2[i][29], file_contents2[i][30], file_contents2[i][31], file_contents2[i][32], file_contents2[i][33]]
          end
       end
     end
   end
  end
  </code></pre>
  
  <p>I'm basically trying to take two individual .csv files and merge certain columns together.  I have two arrays (file_contents and file_contents2) that are reading the individual csv files and storing the contents in arrays.  For some reason i'm getting a syntax error for my if statement. I was hoping someone could help me figure out why the if statement that I wrote isn't valid.  I figured it would be.  Any help is appreciated. Thanks!   </p>