Code now outputs fully formatted HTML document