implement chomp function to remove line endings