There don't seem to be many comments in that code, or helpful things like "use warnings;".
Try closing OUT before opening COL.
What is OUTPUT?
Are there perhaps some files whose last line is missing a newline character? Try chomping all your input and adding "\n" to each print.