Use block semantics for io in formatters.

Closes template files immediately after writing.
Fixes "too many open files" issue when running on large projects.
Reduce duplication and make formatters consistent.
Fix yardoc indentation.
Guard against invalid io arguments.
Merge pull request #104 from robincurry/bug/io

Use block semantics for io in html formatter.