I've written some code (below) which worked fine until i added a statement to write it to a file. 

The error i get is TypeError: unsupported operand type(s) for %: 'NoneType' and 'float' which occurs on line 43.

What is confusing me is the fact that it doesn't throw this error when i use the exact same statements to print only when i write. I've looked through others with this error but can't work out whats going on in my case. 

I've tried to break it down by each line to see if its prevalent through each write statement and it is. 

If anyone can point me in the right direction that would be great thanks.

```
import time

timeOfday = int((time.strftime("%H")))

if timeOfday < 11:
    meal = "Breakfast"
elif timeOfday >=11 and timeOfday <= 5:
    meal = "Lunch"
else:
    meal = "Dinner"

fileName = meal + " " + (time.strftime("%d%m%Y")) +".txt"

print "Hello, Please let us know how much your bill was"
billAmount = float(raw_input(">>"))

print "How much would you like to tip?"
tipAmount = float(raw_input(">>"))

print "How many people are paying?"
peopleAmount = float(raw_input(">>"))

if tipAmount > 1:
    tipAmount = tipAmount / 100

billAndTip = ((billAmount*tipAmount)+billAmount)
finalTip = (billAmount * tipAmount)
billDivided = (billAndTip / peopleAmount)

print "The total bill is %r" % (billAndTip)
print "Of which %r is the tip" % (finalTip)

if peopleAmount == 1:
    print"Looks like you are paying on your own"

else:

    print "Each Person is paying: %r" % (billDivided) 

target = open(fileName, 'w')
# target.write("The bill was %r before the tip \n You tipped %r% \n The total bill was %r \n Split between %r people it was %r each") % (billAmount, tipAmount*100, billAndTip, peopleAmount, billDivided)
target.write("The bill was %r before the tip") % (billAmount)
target.write("\n")
target.write("You tipped %r%") % (tipAmount)
target.write("\n")
target.write("The total bill was %r") % (billAndTip)
target.write("\n")
target.write("Split between %r people it was %r each") % (peopleAmount, billDivided) 
target.close()

print "This info has now been saved for you in the file %r" % (fileName)

```