Q:

In python, newStr+":"+otherStr becomes newStr+"\n"+":"+otherStr

I hope the title wasn't too confusing, but you'll see what I meant by that in a bit. In the meantime, some backstory-- I'm working on a function that generates random usernames and passwords and writes them in a text file as username:password for another program that collects the username:password line as:
string = line.split(":")
username = string[0]
pwd = string[1]

Why does this matter? Well, when I run my function:
Code:
# To generate users and passwords for the password file:
"""
Usage: count-- how many accounts to generate
file-- where to dump the accounts
method-- dict is where it loops through words 
and chooses random ones as users and passwords,
and brute (not implemented yet) is where it chooses
random characters and strings them together as users
and passwords.
users-- if you want any filled in users, put them in here.
passes-- if you want any filled in passes, put them in here.
"""
def genAccts(count, file, method="dict", users=[], passes=[]):
    try:
        f = open(file, "w")
        if method == "dict":
            dictionary = "Dictionary.txt"#input("[*] Dictionary file: ")
            d = open(dictionary, "r")
            words = d.readlines()
            d.close()
            accts = []
            for b in range(0, count):
                global user
                global pwd
                user = random.choice(words)
                pwd = random.choice(words)
                if b < len(users)-1:
                    user = users[b]
                if b < len(passes)-1:
                    pwd = passes[b]
                acct = [user, pwd]
                accts.append(acct)
            print("[+] Successfully generated",count,"accounts")
            for acct in accts:
                combined = acct[0]+":"+acct[1]
                print(combined)
                f.write(combined)
            f.close()
            print("[+] Successfully wrote",count,"accounts in",file+"!")
    except Exception as error:
        return str(error)

genAccts(50, "brute.txt")

In my password file brute.txt, I get an output like
quainter
:slightest
litany
:purples
reciprocal
:already
delicate
:four

and so I'm wondering why is a \n added after the username?

A:

You can fix this by replacing:
words = d.readlines()

with:
words = [x.strip() for x in d.readlines()]

