Well, you need to read from both files.. check from one string and compare it with the other one, and if they're the same, then write it once on the other file... basically, just create a new file based on these two files... compare them line by line.. or however you want to implement it..
if you don't want the two files to exists, you can delete them too

I don't see it difficult to be implemented..