in reply to Compare the content of two files

The obligatory answer is that I'd recommend using a module - for instance:

Other than that, the above code is pretty mangled - you're reading in the whole file, then walking through it chomping lines, then comparing the end results of the loops. I'd take a little time to think about what you're trying to do in the above.