def write_html_file(filename, bytescontent, print_msg=True):
    """
    Helper function for testing etc.
    Wraps the HTML fragment generated by the Writer in a complete document.
    Writes that document to a file.
    """
    with open(filename, 'wb') as out:
        out.write(b'<!DOCTYPE html>\n')
        out.write(b"<html><head><meta charset='utf-8' /></head><body>\n")
        out.write(bytescontent)
        out.write(b'\n</body></html>')
    if print_msg:
        print('##### wrote RTF as XHTML to', filename)
