in reply to comparing 2 files and creating third file with uncommon content
I think you may be missing something in your concept of arrays. Your while loops are overwriting them on each iteration which is probably not what you want. Your foreach loops are then looping over what is actually just a single value, again not what you want.
To illustrate, you could dump the arrays after reading them in purely as a debugging exercise (ie. after the conclusion of the second while loop).
I would very strongly recommend that you use strict and warnings also.