trim trailing newlines