Python sys.stdout.flush() , flush every thing before it
<p>I am new to python and i have a program witch is some king of showing percentage in the command line:</p>

<pre><code>sys.stdout.write("[")

    for x in xrange(1,int(number)):

        percentage = (x*100)/int(number)
        numberfile.write(str(x)+'\n') 

        sys.stdout.write("\r%d%%" %percentage)
        sys.stdout.flush()

    sys.stdout.write("][Done]")
</code></pre>

<p>but my problem is the flush() function, delete all output before it and out put is something like this :</p>

<blockquote>
  <p>100%][Done]</p>
</blockquote>

<p>How i can change it to</p>

<blockquote>
  <p>[100%][Done]</p>
</blockquote>
