now writes output