def read_qids(fname):
    """Reads the query id file, used typically with ranking
    
    Parameters
    ----------
    fname : string
        input file name
        
    Returns
    -------
    Q : list of n_queries index lists
    """
    f = open(fname)
    qids = []
    for line in f:
        qid = line.strip()
        qids.append(qid)
    #Check that at least some queries contain more than one example
    if len(qids) == len(set(qids)):
        raise Exception("Error in the qid file: all the supplied queries consist only of a single example\n")
    f.close()
    return qids