Now the output is valid.

Still more work to be done...