title: Python File Matching and Line Printing
body: <p>I'm trying to expand the below code (thanks to Carles Mitjans) so that if there's a match between file1 and file2 i.e. 12345 from file2 and 12345 from file1 that it prints the full line including paths for however many matches there are between the two files.</p>
  
  <p>However I can't seem to change the intersection into something that would allow this.</p>
  
  <pre><code>file1 example                    file2 example
  12345 /users/test/Desktop        543252 
  54321 /users/test/Downloads      12345  
  0000  /users/test/Desktop        11111
                                   0000
  
  
  with open('Results.txt', 'r') as file1:
      with open('test.txt', 'r') as file2:
          a = set(x.split()[0] for x in file1)
          b = [x.rstrip() for x in file2]
          same = a.intersection(b)
          for line in same:
              print line
  
  same.discard('\n')
  </code></pre>
  
  <p>It currently outputs 
  12345
  0000</p>
  
  <p>Any pointers of guidance would be gratefully received.</p>