title: Loop through two files Ruby
body: <p>What's the neatest way to iterate over two files simultaneously, so that if line 57 in file_1 == 'x' then treat line 57 in file_2 this way?</p>
  
  <p>My code below isn't working, but I know there is a simple solution out there...</p>
  
  <pre><code>@blue = []
  @red = []
  
  file_1 = File.open('index.txt', 'r')
  file_2 = File.open('index2.txt', 'r')
  
  for item, line in file_1, file_2
     @blue &lt;&lt; line if item == "blue"
     @red &lt;&lt; line if item == "red"
  end
  
  file_1.close
  file_2.close
  </code></pre>