Cleanup unused code and comments.
Support append and overwrite. Make JUnit test compare expected content.