I am really new at python and looking for a little help. I have a text file with the current data:

```
Tue Jun 25 **15** 336 0 0 0 0 0
Tue Jun 25 **04** 12682 0 0 0 0 0 
Tue Jun 25 **05** 12636 0 0 0 0 0
Tue Jun 25 **06** 12450 0 0 0 0 0 
Tue Jun 25 **07** 12640 0 0 0 0 0 

```

I want to go through each line and check to see if the  is greater then 12. If it is greater then 12 i want to subtract 12 from it then write back to the with the new number. 

below is the code that i have so far:

```
infile = open("filelocation", "a+") #open the file with the data above and append /             open it

def fun (line, infile): # define a function to to go to position 12 - 14 (which is      where the date in bod is) and set it to an integer 
    t = infile[12:14]
    p = int(t)

    if p > 12: # here is the logic to see if it is greater then 12 to subtract 12 and attempt to write back to the file.
        p = p - 12

        k = str(p)
        infile.write(k)
    else:
        print p # probably not needed but i had it here for testing
    return

# I was having an issue with going to the next line and found this code.
for line in infile:
    print line, infile
    line = fun(line, infile.next())
    break
infile.close()

```

The main issue is it is not iterating through each line or making the update. There even might be a better way to do what i am trying to do just don't have the knowledge yet or understand the capability of some of the functions. Any help with this will be much appreciated!