My loop and File I/O
<p>How do I get my loop to write to the file until I stop the loop?</p>

<p>For example</p>

<pre><code>outFile = "ExampleFile.txt", "w"
example = raw_input(" enter number. Negative to stop ")
while example &gt;= 0:
    example = raw_input("enter number. Negative to stop")
    outFile.write("The number is", example,+ "\n")
</code></pre>

<p>I feel like im hitting it close but I'm not sure. I wasn't sure how to search for this question in paticular. Sorry, I keep getting a error stating that the function takes 1 argument, when I enter more than 2.</p>

<pre><code>import os.path
outFile = open("purchases.txt","w")
quantity = float(raw_input("What is the quantity of the item :"))
cost = float(raw_input("How much is each item :"))


while quantity and cost &gt;= 0:
    quantity = float(raw_input("What is the quantity of the item :"))
    cost = float(raw_input("How much is each item :"))
    total = quantity * cost
    outFile.write("The quantity is %s\n"%(quantity))
    outFile.write("the cost of the previous quality is $s\n" %(cost))
    outFile.close()
    outFile = open("purchases.txt","a")
    outFile.write("The total is ",total)
    outFile.close()
</code></pre>
