<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write(s, path, encoding="utf-8"):
 """Write string to text file. """

    is_gzip = is_gzip_file(path)

    with open(path, "wb") as f:
        if is_gzip:
            f.write(zlib.compress(s.encode(encoding)))
        else:
            f.write(s.encode(encoding))