'Not enought values to unpack when parsing passwords file

I am trying to write a simple login system and keep getting value error on one line

error:

File "/Users/davidjohns/Desktop/Loginsystem/hw4.py", line 44, in <module>
    access(option)
  File "/Users/davidjohns/Desktop/Loginsystem/hw4.py", line 30, in access
    login(name,password)
  File "/Users/davidjohns/Desktop/Loginsystem/hw4.py", line 9, in login
    a,b = i.split(",")
ValueError: not enough values to unpack (expected 2, got 1)
for i in file:
         a,b = i.split(",")
         b = b.strip()
         if(a==name and b==password):
             success = True
             break
granted = False
def grant():
    global granted
    granted = True
def login(name,password):
    success = False
    file = open("passwords.txt","r")
    for i in file:
         a,b = i.split(",")
         b = b.strip()
         if(a==name and b==password):
             success = True
             break
    file.close()
    if(success):
        print("Login Successful")
        grant()
    else:
        print("wrong user name or password")
        
def register(name,password):
    file = open("passwords.txt","a")
    file.write("\n"+name+","+password)
    grant()
def access(option):
    global name
    if(option=="login"):
        name = input("Enter your name: ")
        password = input("Enter your password: ")
        login(name,password)
    else:
        print("Enter your name and password to register")
        name = input("Enter your name: ")
        password = input("Enter your password: ")
        register(name,password)

def begin():
    global option
    option = input("Login or Register (Login,Reg): ")
    if(option!="login" and option!="reg"):
        begin()
        
begin()
access(option)

if(granted):
    print("### USER DETAILS ###")
    print("Username: ",name)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source