def delete_residues(fhandle, residue_range, step):
    """Deletes residues within a certain numbering range.
    """
    prev_res = None
    res_counter = -1
    records = 'ATOM', 'HETATM', 'TER', 'ANISOU'
    for line in fhandle:
        if line.startswith(records):
            res_id = line[21:26]
            if res_id != prev_res:
                prev_res = res_id
                res_counter += 1
            if int(line[22:26]) in residue_range and res_counter % step == 0:
                continue
        yield line
