Issue Python code matching files
<p>Recently with help of stackoverflow i came to know how to match text files using python now im facing some small problem with same code...it performs following task</p>

<p>Input to program is two text files
File 1</p>

<pre><code>C1orf159

FAM79A

IGFBP2

RNF25
.

.

.

.
</code></pre>

<p>File 2</p>

<pre><code>ACVR2B

CACNA1A

RNF25

IGF2

.

.

.
</code></pre>

<p>I wrote one python script to extract common words between these two files as follows</p>

<pre><code>file1=open("f1.txt","r")
file2=open("f2.txt","r")
file3=open("overlap.txt","w")

list1=file1.readlines()
list2=file2.readlines()

for line1 in list1:
     for line2 in list2:
       if line1.strip() in line2.strip():
          print line2
      file3.write(line2)
</code></pre>

<p>this gives result as follows</p>

<pre><code>RNF25

IGF2

.

.

.
</code></pre>

<p>But there is a problem in this output second word IGF2 is not there in file1...script is matching IGFBP2 from file1 with IFG2..meaning it is looking for patterns... I dont want this i want exact matches between two files..</p>

<p>Can anybody help to modify my script to get exact matches between two files...</p>

<p>Thanks
Ni</p>
