<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def echo(*args, **kwargs):
 """ Write a message to a file. Arguments: args A list of arguments which make up the message. The last argument is the path to the file to write to. """

    msg = args[:-1]
    path = fs.path(args[-1])
    append = kwargs.pop("append", False)

    if append:
        with open(path, "a") as file:
            print(*msg, file=file, **kwargs)
    else:
        with open(fs.path(path), "w") as file:
            print(*msg, file=file, **kwargs)