<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_phi_comps_from_recfile(recfile):
 """read the phi components from a record file by iteration Parameters recfile : str pest record file name Returns ------- iters : dict nested dictionary of iteration number, {group,contribution} """

    iiter = 1
    iters = {}
    f = open(recfile,'r')
    while True:
        line = f.readline()
        if line == '':
            break
        if "starting phi for this iteration" in line.lower() or \
            "final phi" in line.lower():
            contributions = {}
            while True:
                line = f.readline()
                if line == '':
                    break
                if "contribution to phi" not in line.lower():
                    iters[iiter] = contributions
                    iiter += 1
                    break
                raw = line.strip().split()
                val = float(raw[-1])
                group = raw[-3].lower().replace('\"', '')
                contributions[group] = val
    return iters