title: Having trouble with a while loop, it breaks, even though it shouldn't
body: <p>I'm having trouble with a while loop!  </p>
  
  <p>What I'm trying to do is to make a simple account creation system.   I want the user to enter a username, if the username already exists, It should let me try again.</p>
  
  <p>But even if the username exists, it continues the function, and asks me for a password, and writes the username and password to the file.</p>
  
  <p>here's the code:</p>
  
  <pre><code>def create_user():
      passw = open('passwords.txt', 'r+')
      x = 1
      passwr = passw.readlines()
      print "What's your username?"
  
      while x == 1:
          user = raw_input("&gt;&gt; ")
          for l in passwr:
              a = l.split()  
              if user.lower() not in a[0]:
                  x = 0
  
              else:
                  print 'Sorry, that\'s already in use!'
  
      print "What's your pw?"
      pw = raw_input("&gt;&gt; ")
      passw.seek(0, 2)
      passw.write(user + ' ' + pw + '\n')
  </code></pre>
  
  <p>The file is formated like this:</p>
  
  <pre><code>Username1 Password
  Username2 Password
  </code></pre>
  
  <p>I've tried to figure out what's wrong for a while now. But can't seem to figure out a solution.</p>