import re


def section_exists(filename, version, print_message=True):
    """
    Check given file for existing section with specified version.
    """
    for i, line in enumerate(open(filename)):
        if re.search(r'^## ' + version, line):
            if print_message:
                print("  Existing section for v{0} found,"
                      .format(version), end=" ")
            return True
    return False