strip trailing newlines