in reply to newline substitution is removing text too
There are probably also carriage returns in the file as well. tr/\r//d or s/\r//g will remove them.
In Section
Seekers of Perl Wisdom
in reply to newline substitution is removing text too