Replace "while" with "for" in given python script
<p>I have written following script in python which works fine:</p>

<pre><code>from sys import argv

script, filename = argv

def brokerage(cost):
    vol = 100
    tamt = cost*vol
    br = (((cost*0.1)/100)*vol)*2
    rc = (0.0074*tamt)/100
    stt = (0.025*tamt)/100
    std = (0.004*tamt)/100
    stb = (11*br)/100
    tbr = br+rc+stt+std+stb
    return(tbr)

cost1 = 10
cost2 = 510

while cost1 &lt; 501 and cost2 &lt; 1001:
    value1 = brokerage(cost1)
    value2 = brokerage(cost2)
    # Can't write 'float' to file so, changed it into string. Don't know why.
    x1 = str(value1)
    x2 = str(value2)
    line = "  |%d\t\t%s\t|\t|%d\t\t%s\t|" % (cost1, x1, cost2, x2)
    # use 'a' in 'open' function to append it, will not overwrite existing value
    # as with 'w'.
    save = open(filename, 'a')
    save.write(line)
    save.write("\n  |---------------------|\t|-----------------------|\n")
    save.close
    cost1+=10
    cost2+=10
</code></pre>

<p>Now instead of "while" I want to use "for" with minimal code structure change.</p>
