public function readUntil($end)
    {
        if (empty($end)) {
            throw new ResourceException("Empty string given to Reader::readUntil()");
        }
        fseek($this->resource, $this->readPosition);
        // Reading the first character (maybe blocking)
        $buffer = stream_get_contents($this->resource, 1);
        // saving the blocking mode
        $mode = $this->blocking();
        $size = strlen($end);
        $this->blocking(false);
        while (strlen($buffer) < $size || substr($buffer, -$size) != $end) {
            $c = stream_get_contents($this->resource, 1);
            if (empty($c)) {
                break;
            }
            $buffer .= $c;
        }
        $this->blocking($mode);
        $this->readPosition = ftell($this->resource);
        return (substr($buffer, -$size) == $end)
            ? substr($buffer, 0, strlen($buffer) - $size)
            : $buffer;
    }