code: def sink_to_file(
      filename, upstream, mode="w", prefix="", suffix="\n", flush=False
  ):
      file = open(filename, mode=mode)
  
      def write(text):
          file.write(prefix + text + suffix)
          if flush:
              file.flush()
  
      upstream.sink(write)
      return file
  
imports: import asyncio
  from glob import glob
  import queue
  import os
  import time
  from tornado import gen
  import weakref
  from .core import Stream, convert_interval, RefCounter, sync
label_desc: Use image node_id 1 for calling a global function with example usage: sink_to_file(filename, upstream, mode, prefix, suffix, flush) and returns: file