in reply to Reading and *writing* configuration files

For what it's worth, Webmin has a nice BIND module that reads and writes BIND configuration files (all of them), and it respects comments and the existing formatting.

The code isn't as modular as one might like, but it is thoroughly readable in all of the modules I've studied. It is probably worth looking into as a working example.

It can be found here: http://www.webmin.com