But what you are doing now is slurping in the whole file and adding an extra newline at the end of each line (for which I see absolutely no reason). The same thing can be achieved by undefing $/ like this: