public function read(callable $callback = null) {
		if (!$this->isValid()) {
			throw new ConnectionException('Connection not valid');
		}
		$promptLine = $this->readLine(); //first line is prompt
		$this->parser->checkConnectionError($promptLine);

		$output = [];
		if (!$this->isPrompt($promptLine)) {
			$line = $promptLine;
		} else {
			$line = $this->readLine();
		}
		if ($line === false) {
			$this->unknownError($promptLine);
		}
		while (!$this->isPrompt($line)) { //next prompt functions as delimiter
			if (is_callable($callback)) {
				$result = $callback($line);
				if ($result === false) { // allow the callback to close the connection for infinite running commands
					$this->close(true);
					break;
				}
			} else {
				$output[] .= $line;
			}
			$line = $this->readLine();
		}
		return $output;
	}