Saving user details into a file in a login system?
<p>I am producing a turn based game for a project and would like to create a user login system that saves the user's login username and password into a file in the game folder location. I would hope to then use the notepad file to check if there is already an account with that username when new users try to create a login.</p>

<p>In this code i attempted this but it is wrong?!</p>

<pre><code>filename = 'UserInfo.txt' 
openfile = open(filename, "r")                                                          
UserData = openfile.readline()  
def displayMenu():
    print (UserData)
    status = input("Are you a registered user? y/n? ")  
    if status == "y":
        oldUser()
    elif status == "n":
        newUser()

def newUser():
    createLogin = input("Create login name: ")

    if createLogin in UserData:
        print ("Login name already exist!")
    else:
        createPassw = input("Create password: ")
        UserData[createLogin] = open('UserInfo','w')
        print("User created!")     
def oldUser():
    login = input("Enter login name: ")
    passw = input("Enter password: ")
    if login in UserData and UserData[login] == passw: 
        print ("Login successful!")
    else:
        print ("User doesn't exist or wrong password")
displayMenu()
</code></pre>