Separated the actual file writing of an HTML document into a separate htmlDoc method.