Strip trailing newlines from dictionaries