I'm making a dice game for a school project. When you start the game you input your name and it need to read from the file "Player_Names.txt" the list of names of players who played before if the name isn't on the list then they get a "welcome" but if it is they get a "welcome back".
With my current code what happens is it only reads the 1st line in the file so if the name isn't on the 1st line it'll give back a message for welcoming a new player. Also if its part of a name so if you first enter "Matthew" and then another time enter "Matt" it will give you a "welcome back" message but "Matt" is a different person so it should be a "welcome" message. Also if the Name you enter is on the list but on the 2nd line in the file you get nothing back the program just continues to the next line of code.
Names = open("Player_Names.txt", "r+")
player1 = input("Enter your name: ")
if player1 in Names.readline():
print("Welcome back you are player 1")
elif player1 not in Names.readline():
print("Welcome you are player 1")
Names.write(player1)
Names.write("\n")
How can I get the programe to read all the lines and treat the words inputed as whole words not letters like in the "Matthew" example?