I tried many things but most of them just got stuck or didn't remove the duplicates properly. It doesnt matter if the output file is sorted or not
If file1.txt contains
a
b
c
d
e
c
d
If file2.txt contains
c
d
e
a
f
g
g
h
output.txt should contain
a
b
c
d
e
f
g
h