def METHOD_NAME(self, flow: flow.Flow) -> None:
    """
    Write the flow to the stream, but first check if we need to rotate to a new file.
    """
    if not self.stream:
        return
    try:
        self.maybe_rotate_to_new_file()
        self.stream.add(flow)
    except OSError as e:
        # If we somehow fail to write flows to a logfile, we really want to crash visibly
        # instead of letting traffic through unrecorded.
        # No normal logging here, that would not be triggered anymore.
        sys.stderr.write(f"Error while writing to {self.current_path}: {e}")
        sys.exit(1)
    else:
        self.active_flows.discard(flow)