Remove trailing newlines and add sock