As a rule of thumb (correct me if I'm wrong here), try to use 'chomp' instead of chop, as chop merely kills the last character in the line, while chomp kills the last whitespace character (or none if the last character is alphanumeric).
Could you post a sample file to go with this?
Hope this helps!
_________________________________________
E-Bitch
Tempora Mutantur Nos et Mutamur in Illis
"The Times are Changed Even as We are Changed in Them"