code: def _write_to_error(self, s, truncate=False):
          
          # if truncate is True, set write mode to truncate
          with open(self._errorfile, 'w' if truncate else 'a') as fp:
              fp.writelines((to_text(s)), )
docs: Writes the given output to the error file, appending unless `truncate` is True.