Use block semantics for io in formatters.

Closes template files immediately after writing.
Fixes "too many open files" issue when running on large projects.