There is a way to make a request every .txt file line? : <p>I'm doing a roblox name checker. Only except code works.</p>

<p>I've tried things like with open(...)as f:,etc.</p>

<pre class="lang-py prettyprint-override"><code>with open('usernames.txt') as f:
    for line in f:
        a=requests.get('https://api.roblox.com/users/get-by-username?username=%s' % line)
        r=json.loads(a.content)

    try:
        if r["success"]== False:
            print("Username avaliable ["+line+"]")
            f=open("free.txt",'a')
            f.write('n')
            f.close()
     except:
        print("Username taken ["+line+"]")
        file=open("taken.txt",'a')
        file.write(line)
        file.close()



</code></pre>
