def delete_insertions(fhandle, option_list):
    """Deletes insertion codes (at specific residues).

    By default, removes ALL insertion codes on ALL residues. Also bumps the
    residue numbering of residues downstream of each insertion.
    """
    if not option_list:
        has_option = False
    else:
        option_set = set(option_list)
        has_option = True
    offset = 0
    prev_resi = None
    seen_ids = set()
    clean_icode = False
    records = 'ATOM', 'HETATM', 'ANISOU', 'TER'
    for line in fhandle:
        if line.startswith(records):
            res_uid = line[17:26]
            id_res = line[21] + line[22:26].strip()
            icode = line[26]
            if prev_resi != res_uid:
                if id_res in seen_ids:
                    if has_option and id_res not in option_set:
                        clean_icode = False
                    else:
                        clean_icode = True
                        line = line[:26] + ' ' + line[27:]
                        offset += 1
                elif icode != ' ':
                    if has_option and id_res not in option_set:
                        pass
                    else:
                        if id_res in seen_ids:
                            offset += 1
                        clean_icode = True
                        line = line[:26] + ' ' + line[27:]
                else:
                    clean_icode = False
                prev_resi = res_uid
            if clean_icode:
                line = line[:26] + ' ' + line[27:]
            resid = int(line[22:26]) + offset
            line = line[:22] + str(resid).rjust(4) + line[26:]
            seen_ids.add(id_res)
            if line.startswith('TER'):
                offset = 0
        yield line
