Refactor all `.write()` calls into one function.

In Doorstop, all text files should be explicitly UTF-8. To avoid specifying encoding in multiple places, create one writer function.