Q:

Reading a list from a file in python 3

While trying to make a simple register/signup client only application for a personal project. I'm trying to load a list of users from a file, and compare them to a possible username. If the username already exists, the program will give them an error.
Here is a condensed clone of the code:
    u1 = str(input("Input username: "))
    t = open("userlistfile","r")
    userlist = t.readline()
    y = 0
    for x in range(0, len(userlist)-1):
        if userlist[y] == u1:
            print("\n !Error: That username (",u1,") is already taken!")
        y += 1

The user list is stored in a file so that it can opened, appended, and saved again, without being stored in the program. My current issue is that the userlist is saved as a string rather than an array. Is there a better way to do this? Thank you.  

EDIT: Thanks to user lorenzo for a solution. My Friends are telling me to post a quick (really simple) copy of a for you guys who can't figure it out.
New code: 
    u1 = str(input("Input username: "))
    t = open("userlistfile","r")
    userlist = t.read()              #Readline() changed to Read()
    userlist = userlist.split('--')  #This line is added
    y = 0
    for x in range(0, len(userlist)-1):
        if userlist[y] == u1:
            print("\n !Error: That username (",u1,") is already taken!")
        y += 1

Example text file contents:
smith123--user1234--stacky

This line will seperate the string at the ('--') seperators and append each split part into an array: 
userlist = userlist.split('--')
#Is used so that this (in the text file)
Smith123--user1234--stacky
#Becomes (in the program)
userlist = ['Smith123','user1234','stacky']

Sorry for the long post... Found it very interesting. Thanks again to Lorenzo :D.

A:

 userlist = t.readline()

reads one line from the file as a string. Iterating, then, gets characters in the string rather than words.
You should be able to get a list of strings (words) from a string with the  split() method of strings or the more general re.split() function.

