file.txt file2.txt
I'm trying to make a Python script that will do the following:
Read file.txt and file2.txt If there is something that is inside of file.txt which is also inside of file2.txt, remove it from file.txt
This is what I've done:
file1 = open('file.txt', 'r').readlines()
file2 = open('file2.txt', 'r').readlines()
Removed = open('Removed.txt', 'a')
for line in file2:
if line not in file1:
Removed.write(str(line) + '\n')
Removed.close()
It just removed it from file2.txt