fixed ascii error when writing to file