def generate_auth_file(auth_file):
    global auth_key
    if not os.path.isfile(auth_file):
        f = open(auth_file, "wb")
        json_out = {}
        json_out["SecretKey"] = NetMsg.generateKey()
        auth_key = json_out["SecretKey"]
        f.write(json.dumps(json_out))
        f.close()
        # print "created"
    else:
        exit("Authenication file already exists\n")
try:
    if indexData[options.a] == options.c and options.n: #Trying to make a new account when it already exists
        sys.exit(255)
    elif indexData[options.a] != options.c: #The card file you passed does not match the file we expect
        sys.exit(255)
except KeyError:
    for entry in indexData:
        if indexData[entry] == options.c: #If card file is associated with another account
            sys.exit(255)

cardFilePath = os.path.join("./CardFiles", options.c)
try:
    if not os.path.exists(cardFilePath) and options.n:
        cardFile = open(cardFilePath, "w")
        cardPin = NetMsg.generateKey()
        cardFile.write(cardPin)
        cardFile.close()
        
        indexData[options.a] = options.c
        indexFile = open("./CardFiles/index", "w")
        indexFile.write(json.dumps(indexData))
        indexFile.close()
except IOError:
    sys.exit(255)


def getAuthKey():
    key = {}
    numLines = 0
    for line in authFile: