scope rule output writers to the func, to avoid keeping open so many of them