Save pretty printed JSON file after each command.

Ensure that we clean up appropriately after running each command. Also,
to make it is easier to modify files, pretty print the JSON when
marshalling.