def METHOD_NAME(outFile, failedQueryIds):
    if len(failedQueryIds) == 0:
        return
    distOutFileContentAsLines = []
    with open(outFile, "r") as f:
        distOutFileContentAsLines = f.readlines()
    with open(outFile, "w") as f:
        clear = False
        nextIdx = 0
        nextQueryIdToDelete = failedQueryIds[nextIdx]
        queryIdPattern = "queryId: ([0-9]+)"
        for line in distOutFileContentAsLines:
            matched = re.search(queryIdPattern, line)
            # founded line which contains query id
            if matched:
                # query id matches with the next failed query's id
                if nextQueryIdToDelete == matched[1]:
                    # clear lines until we find succesfull query
                    clear = True
                    nextIdx += 1
                    if nextIdx < len(failedQueryIds):
                        nextQueryIdToDelete = failedQueryIds[nextIdx]
                else:
                    # we found successfull query
                    clear = False
            if not clear:
                f.write(line)
    return