Revert "Extract file writing logic from Template."

This reverts commit 3d9e65a1a002421b4673aafe6a7a6bc629a1547b.