Wilha 0 Newbie Poster

My goal is to output monthly cost insrance for entered employee id, but my program keeps giving me a error idk why

import sys
#empfile=raw_input("Enter Emp.file Name:")
#emp=sys.argv[1]
#print emp
#usage : run it as follows from command line.
#python db.py employee.txt InsurancePlans.txt InsurancePolicies.txt   
                                     
            
def dict2(lines):
    dict={}
    for l in lines:
        s=l.split(',')
        key1=s[0]
        #print 'key1 ',key1
        dict[key1]=[]
        for idx,i in enumerate(s):
            if idx>0:dict[key1].append(i)
    return dict                                             
def printnames(d,name):
   for key,data in sorted(d.items()):
       #for idx,nm in enumerate(name):
       if data[1]==name:
           print data[0],data[1]
emp = open(sys.argv[1])
emplines = emp.readlines()
insplan=open(sys.argv[2])
insplanlines=insplan.readlines()
inspol=open(sys.argv[3])
inspollines=inspol.readlines()

empdict=dict2(emplines)
insplandict=dict2(insplanlines)
inspoldict=dict2(inspollines)

#print empdict
print insplandict
print inspoldict

name=raw_input("enter emp.1st name:")
printnames(empdict,name)
id=raw_input("enter emp.ID:")

def dict2(lines):
    dict={}
    for l in lines:
        s=l.split(',')
        key2=s[0]
        #print 'key1 ',key1
        dict[key2]=[]
        for idx,i in enumerate(s):
            if idx>0:dict[key2].append(i)
def printmonthlycost(d,id):
   for key,data in sorted(d.items()):
       #for idx,nm in enumerate(name):
       if data[2]==id:
           print data[1]
		   
printmonthlycost(insplandict,id)