trim trailing empty lines