file output error relating to list dictionary and value
===

So my code works fine but it won't only print out half of the correct result.
I am trying to write a header to a file. I have checked and print out the calculation, which is correct. However, I only got one file print out correctly with the correct number and didn't get the another file to print out. 

lookup[uniprotID] =['177','26','418']

the file that didn't print out correctly has this information : start 174 and end 196.

That file should has this as a result:
>uniprotID | at 3 position
>
YSADACERD

Here is my code.

<code>for i, (start, end) in enumerate(searchPFAM(fname)):
   
    print start, end
    for item in lookup[uniprotID]:
        item, start, end = map(int, (item, start, end))
        
        if start <=end:
            if item in xrange(start, end+1):
                print item
                with open('newfile-%s.txt' % i,'w') as fileinput:
                    atPosition = (item)-start
                    result = str(atPosition)
                    fileinput.write(">"+uniprotID+' | at '+result +' position\n')
                    text=''.join(makeList[(start-1):(end)])
                    fileinput.write(text)
            else:
                with open('newfile-%s.txt' % i,'w') as fileinput:
                    fileinput.write(">"+uniprotID+' | '+ 'N/A\n')
                    
                    text=''.join(makeList[(start-1):(end)])
                    fileinput.write(text)