Beginner Python User Login System
Use with to handle file operations
A common way to handle files is by creating a file instance with open statement and closing it when you are done with the handler, while this would work, it is prone to error. What if you forget to close the file? It leads to either the file not saving or the handler might be corrupted with garbage. with automatically closes the file once operations on it are done. A simple example is as follow
with open('usernames.txt', 'r') as f:
    f.read()

Recursion is expensive
Your choices function uses recursion which might become expensive. Recursion creates temporaries in the stack frame and as it recur more and more, your stack frame might eventually be filled, though it can be elegant to solve a problem with recursion, limit it usage. Any function that can be written recursively can also be written with an iterative approach. Iterative approach tends to be faster and does not create temporaries
Consider reducing the complexity of choices
Right now choice does way too much, signs up a user and also login a user. Your functions should do just one thing and do it very well. The name choices is very misleading, from the name, I would expect it to make a choice or rather I make a choice among a list of values, rather is suprisingly signs up and login a user. Avoid function side-effect. Function side-effect is when a function promises one thing and does another.
Use a dictionary pair
I really think a dictionary is needed in this scenario. Dictionaries as we all know are very fast. Storing a key-value pair of username and password makes the code clean and easy to reason about.
Detour

You might want to use open('filename.txt', 'a') when you want to append to a file, using 'w' overwrites the content of the file and is similar to calling truncate on the file.

When you want to recieve string input, no need for this statement str(input(&quot;Enter&quot;)), input automatically recieves strings.

Avoid variable names suchh as f


This is an editted version of the code
def signup():
    with open(&quot;usernames.txt&quot;, 'r') as user:
        usernames = user.read().splitlines()
    with open(&quot;passwords.txt&quot;, 'r') as pwd:
        passwords = pwd.read().splitlines()
    
    info = dict(zip(usernames, passwords))

    print(&quot;Please Provide&quot;)
    username = input(&quot;Username: &quot;)
    while username in info.keys():
        print(&quot;Username unavailable. Please Try Again.&quot;)
        username = input(&quot;Username: &quot;)      
    password = input(&quot;Password: &quot;)   
    
    with open(&quot;usernames.txt&quot;, 'a') as user:
        user.write(username + '\n')
    with open(&quot;passwords.txt&quot;, 'a') as pwd:
        pwd.write(password + '\n')
    
    print(&quot;Congratulations! You have successfully created an account. You may now login in.&quot;)

def login():
    with open(&quot;usernames.txt&quot;, 'r') as user:
        usernames = user.read().splitlines()
    with open(&quot;passwords.txt&quot;, 'r') as pwd:
        passwords = pwd.read().splitlines()
    
    info = dict(zip(usernames, passwords))
    username = input(&quot;Username: &quot;))
    password = input(&quot;Password: &quot;))

    if info.get(username, None) is None:
        print(&quot;Your username is either incorrect or nonexistent. You can either try again or create a new account.&quot;)
        signup()
        return

    if password != info[username]:
        print(&quot;Your password is incorrect. Please try again.&quot;)
        return

    print(&quot;Welcome Back &quot; + username + &quot;!&quot;)      

if __name__ == '__main__':
    print(&quot;Please choose what you would like to do.&quot;)
    choice = int(input(&quot;For Signing Up Type 1 and For Signing In Type 2: &quot;))
    if choice == 1:
        signup()
    elif choice == 2:
        login()