factor save_html function out of print_html