def METHOD_NAME(token, file, ttl):
    """
    This method will add a token to the token file with or without expiry
    Expiry time is in seconds.
    Format of the item in the file: <token>|<expiry in seconds>
    :param str token: The token to add to the file
    :param str file: The file name for which the token will be written to
    :param ttl: How long the token should last before expiry, represented in seconds.
    """
    with open(file, "a+") as fp:
        if ttl != -1:
            expiry = int(round(time.time())) + ttl
            fp.write(token_with_expiry.format(token, expiry))
        else:
            fp.write(token_without_expiry.format(token))