Removing garbage at the end of a line