<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def show_qouts(self, nids=None, stream=sys.stdout):
 """ Write to the given stream the content of the queue output file for all tasks whose status is S_QCRITICAL. Args: nids: optional list of node identifiers used to filter the tasks. stream: File-like object. Default: sys.stdout """

        lines = []

        for task in self.iflat_tasks(status=self.S_QCRITICAL, nids=nids):
            header = "=== " + task.qout_file.path + "==="
            lines.append(header)
            if task.qout_file.exists:
                with open(task.qout_file.path, "rt") as fh:
                    lines += fh.readlines()
            else:
                lines.append("File does not exist!")

            lines.append("=" * len(header) + 2*"\n")

        return stream.writelines(lines)