compare two files' contents extracting different contents in python
<p>I have two files, file1 contains contents as </p>

<blockquote>
  <p>aaa  </p>
  
  <p>bbb  </p>
  
  <p>ccc</p>
</blockquote>

<p>and file 2 contains contents as </p>

<blockquote>
  <p>ccc</p>
  
  <p>ddd</p>
  
  <p>eee</p>
  
  <p>aaa</p>
  
  <p>rrr</p>
  
  <p>bbb</p>
  
  <p>nnn</p>
</blockquote>

<p>I would like to do like this, if file2 contains file1's line, then that line would be removed from file2. At last, file2 will be as ddd
                                      eee
                                      rrr
                                      nnn
Besides, my code is </p>

<pre><code>f1 = open("test1.txt","r")
f2 = open("test2.txt","r")

    fileOne = f1.readlines()
    fileTwo = f2.readlines()
    f1.close()
    f2.close()
    outFile = open("test.txt","w")
    x = 0
    for i in fileOne:
        if i !=  fileTwo[x]:
            outFile.writelines(fileTwo[x])
        x += 1

outFile.close()
</code></pre>

<p>Thank you.</p>
