def write(self, data, end="\n", flush=True):
        """ Output data to stdout and/or file """
        if not self.nostdout:
            self.stdout.write(data+end)
        if self.file is not None:
            self.file.write(data+end)
        if flush:
            self.flush()
Output data to stdout and/or file