Added comments to write_output()

...Still doesn't work, but should be easier to debug now.