Factor out _written.