trim leading and trailing newlines