Better implementation of HTML file generation