def get_lineno(to_match, filename, search_from=None):
    """
    Get the line number that matches the pattern in a file.

    :param to_match: The pattern to match.
    :type to_match: str
    :param filename: The file name to search.
    :type filename: str
    :param search_from: Search from some position in the file.
    :type search_from: str or None
    :return: The line number found or None if not found.
    :rtype: str or None
    """

    to_match = str(to_match)
    with open(filename) as f:
        lineno = 0
        for line in f:
            lineno += 1
            if search_from:
                if line.__contains__(search_from):
                    search_from = None
            else:
                if line.__contains__(to_match):
                    return lineno
    f.close()