zigbee.getnodelist() and file

Dear All,
I want to register “64-bit address” and identify in a file for use after.
like this:
file.txt:

src_addr1 : label1
src_addr2 : label2

the node (src_addr1) send data ,i check if (src_addr1) exsit int the file or not
if not ,i scan the network and i add it in the file.

payload, src_addr = sd.recvfrom(255)
def check(key):     
datafile = file('textfile.txt')     
for line in datafile:
         if key in line:
             found = True
         else:             
            found = False     
return found 
if check(src_addr):
     print "true" 
else:     
     print "false"  
     #scan network with zigbee.getnodelist()
     #add the label of the src_addr 
     nodes = zigbee.getnodelist(refresh=True)
     # We use filter to remove any coordinators from our list
     nodes = filter(lambda x: x.type != 'coordinator', nodes)    
    for node in nodes:
       Label = node.label
       print Label
       AddrShort = node.addr_short
       print AddrShort
       AddrExtend = node.addr_extended
       print AddrExtend     
with open("textfile.txt","a+") as f :                   
     f.writelines("
%s:%s"%(AddrExtend,Label")) 

but i have problem in this block:

  for node in nodes:        
Label = node.label        
print Label        
AddrShort = node.addr_short        
print AddrShort        
AddrExtend = node.addr_extended        
print AddrExtend      
with open("textfile.txt","a+") as f :
f.writelines("
%s:%s"%(AddrExtend,Label"))