this code works perfectly the only problem it doesnt work with Large txt files . 1GB text file . What can I do to fix?
import os
file_1 = open('file1.txt', 'r', encoding='utf8').read().splitlines()
file_2 = open('file2.txt', 'r', encoding='utf8').read().splitlines()
[file_2.remove(l) for l in file_1 if l in file_2]
with open('file2.txt', 'w') as new_file:
[new_file.write(l + '\n') for l in file_2]