in reply to find unique lines in two files

Have you read the FAQ How do I compute the difference of two arrays? How do I compute the intersection of two arrays? You might find that instructive.

I'd also humbly suggest that indenting your code might make it a bit more legible and maintainable.