fixed writing output for conversion