docs: def write_ndjson(filename, data_iterable, append=False, **kwargs):
      """
      Generator that writes newline-delimited json to a file and returns items
      from an iterable.
      """
      write_mode = "ab" if append else "wb"
      logger.info("writing to file {}".format(filename))
      with codecs.open(filename, write_mode, "utf-8") as outfile:
          for item in data_iterable:
              outfile.write(json.dumps(item) + "\n")
              yield item