title: Python Login Script; Usernames and Passwords in a separate file
body: <p>I'm looking for assistance to get my Python script to imitate a log-in feature while the credentials are stored in a separate file.</p>
  
  <p>I got it to work from hard-coded Username and Password, and it also reads in a file, but I'm having some difficulty finding out how to link the two together.</p>
  
  <p>Any assistance is appreciated.</p>
  
  <p>The Python script is as follows:</p>
  
  <pre><code>print "Login Script"
  
  import getpass
  
  CorrectUsername = "Test"
  CorrectPassword = "TestPW" 
  
  loop = 'true'
  while (loop == 'true'):
  
      username = raw_input("Please enter your username: ")
  
      if (username == CorrectUsername):
          loop1 = 'true'
          while (loop1 == 'true'):
              password = getpass.getpass("Please enter your password: ")
              if (password == CorrectPassword):
                  print "Logged in successfully as " + username
                  loop = 'false'
                  loop1 = 'false'
              else:
                  print "Password incorrect!"
  
      else:
          print "Username incorrect!"
  </code></pre>
  
  <p>I found this somewhere else that helped me read the file in, and it does print the contents of the text file, but I am unsure on how to progress from this:</p>
  
  <pre><code>with open('Usernames.txt', 'r') as f:
      data = f.readlines()
      #print data
  
  for line in data:
      words = line.split() 
  </code></pre>
  
  <p>The text file contains the Usernames and Passwords in a format of: Test:TestPW Chris:ChrisPW Admin:AdminPW with each credential on a new line.</p>
  
  <p>As I said previously, any help is appreciated!
  Thanks.</p>