cleaning-up some mistake in write_output

I had forgotten to make the first write command to file 22 conditional
upon the flag.