Extract file appending methods into traits.  Fixes #9.

This reduces the duplicate code and makes things simpler to locate.