public function write() {
        // Determine the width of the last column.
        $columnWidths = array_sum($this->columnWidths);
        $totalWidth = $this->indent + $columnWidths + $this->padding * (count($this->columnWidths) - 1);

        $lastWidth = end($this->columnWidths) + $this->maxWidth - $totalWidth;
        $lastWidth = max($lastWidth, 10); // min width of 10
        $this->columnWidths[count($this->columnWidths) - 1] = $lastWidth;

        // Loop through each row and write it.
        foreach ($this->rows as $row) {
            $rowLines = [];
            $lineCount = 0;

            // Split the cells into lines.
            foreach ($row as $i => $cell) {
                list($text,) = $cell;
                $width = $this->columnWidths[$i];

                $lines = Cli::breakLines($text, $width, $i < count($this->columnWidths) - 1);
                $rowLines[] = $lines;
                $lineCount = max($lineCount, count($lines));
            }

            // Write all of the lines.
            for ($i = 0; $i < $lineCount; $i++) {
                foreach ($rowLines as $j => $lines) {
                    $padding = $j === 0 ? $this->indent : $this->padding;

                    if (isset($lines[$i])) {
                        if ($this->formatOutput) {
                            if(isset($row[$j])) {
                                $wrap = $row[$j][1];
                            } else {
                                // if we're out of array, use the latest wraps
                                $wrap = $row[count($row)-1][1];
                            }

                            echo str_repeat(' ', $padding).$wrap[0].$lines[$i].$wrap[1];
                        } else {
                            echo str_repeat(' ', $padding).$lines[$i];
                        }
                    } elseif ($j < count($this->columnWidths) - 1) {
                        // This is an empty line. Write the spaces.
                        echo str_repeat(' ', $padding + $this->columnWidths[$j]);
                    }
                }
                echo PHP_EOL;
            }
        }
    }