Refer the given code and let us know in case you have any concerns.
with open('first_file.txt', 'r') as file1:
    with open('second_file.txt, 'r') as file2:
        difference = set(file1).difference(file2)
        difference.discard('\n')
        with open('diff.txt', 'w') as file_out:
        for line in difference:
            file_out.write(line)
Hope this helps!!
If you need to know more about Python, join Python certification course today.
Thanks!