title: Finding common IDs in different .txt files and appending additional corrisponding lines
body: <p>I am trying to find common IDs present in two files and print out the result into a new file appending the additional lines corresponding to those IDs.How can I do this?</p>
  
  <p>Input file1.txt</p>
  
  <pre><code>F775_23607  EMT15298  GO:0003674    molecular_function PF08268  345
  F775_00510  EMT20601  GO:0005515    protein binding    PF08268  456
  F775_00510  EMT23774  GO:0003674    molecular_function PF00646  134
  F775_00510  EMT23774  GO:0005515    protein binding    PF03106  888
  F775_23182  EMT33502  GO:0003677    DNA binding    PF03106  789
  </code></pre>
  
  <p>Input file2.txt</p>
  
  <pre><code>contig15    EMT15298  95.27 148
  contig18    EMT04099  97.95 293 
  contig18    EMT20601  92.83 293 
  contig18    EMT23062  93.17 293
  </code></pre>
  
  <p>Desired output file (I want to be able to decide which lines to print and which not)</p>
  
  <pre><code>EMT15298  GO:0003674 molecular_function PF08268
  EMT20601  GO:0005515 protein binding    PF08268
  </code></pre>
  
  <p>My script (which, basically, prints only the column, which is in common)</p>
  
  <pre><code>fileA = open("file1.txt",'r')
  fileB = open("file2.txt",'r')
  output = open("results.txt",'w')
  fileA.next()
  
  setA = set()
  for line1 in fileA:
      listA = line1.split('\t')
      setA.add(listA[1])
  setB = set()
  for line1 in fileB:
      listB = line1.split('\t')
      setB.add(listB[1])
  for key in setA &amp; setB:
      output.writelines(key+'\n')
  </code></pre>