title: File comparison Ran out of memory
body: <p>Hi i am using this code - but for files > 8 Million rows of lines - 2 files passed as text input, the memory runs out. How can i compare both text files which are more than 30 Million lines maybe.</p>
  
  <pre><code>fileA1 = ARGV[0]
  fileA2 = ARGV[1]
  
  if ARGV.length != 2
    raise 'Send Two files pls'
  end
  cmd = "sort #{fileA1} &gt; Sorted.txt"
  `#{cmd}`
  aFile = File.open("Sorted.txt", "r");
  bFile = File.open(fileA2, "r").readlines;
  fileR = File.open("result.txt", "w")
  
  p aFile.class
  p bFile.class
  p bFile.length
  
  aFile.each do |e|
    if(! bFile.include?(e) )
      p 'Able to get differences:' + e.to_s
      fileR.write('Does not Include:' + e)
    end
  end
  </code></pre>
  
  <p>additional coding i tried without luck. </p>
  
  <pre><code>counterA = counterB = 0
  aFile = File.open("Sample1 - Copy.txt", "r");
  bFile = File.open("Sample2.txt", "r");
  file1lines = aFile.readlines
  file2lines = bFile.readlines
  
  
  file1lines.each do |e|
  if(!file2lines.include?(e))
  puts e
   else
  p "Files include these lines:"
  end
  end
  stopTime = Time.now
  </code></pre>