Python wierd file name on create
<p>I have a txt file with list of html/doc files, I want to download them using python and save them as 1.html, 2.doc, 3.doc, ...</p>

<pre><code>http://example.com/kran.doc
http://example.com/loj.doc
http://example.com/sks.html
</code></pre>

<p>I've managed to create fully functional script except python will allways add question mark to the end of newly created file (if you look from linux) and if you look from windows file name would be something like <strong>5CFB43~X</strong></p>

<pre><code>import urllib2
st = 1;
for line in open('links.txt', 'r'):
        u = urllib2.urlopen(line)
        ext = line.split(".")
        imagefile = str(st)+"."+ext[-1]
        #file created should be something.doc but its something.doc? -&gt; notice question mark
        fajl = open(imagefile, "w+")
        fajl.write(u.read())
        fajl.close()
        print imagefile
        st += 1
</code></pre>
