diff --git a/unistd-input-stream.lisp b/unistd-input-stream.lisp
index 1039456..8edd774 100644
--- a/unistd-input-stream.lisp
+++ b/unistd-input-stream.lisp
@@ -36,6 +36,9 @@
(let ((element (cffi:mem-aref (stream-input-buffer stream) :unsigned-char
(stream-input-index stream))))
(incf (stream-input-index stream))
+ (when (= (stream-input-index stream) (stream-input-length stream))
+ (setf (stream-input-index stream) 0
+ (stream-input-length stream) 0))
(values element nil)))
(defun unistd-input-stream (fd)
diff --git a/unistd-output-stream.lisp b/unistd-output-stream.lisp
index e85e3b2..b69ddb6 100644
--- a/unistd-output-stream.lisp
+++ b/unistd-output-stream.lisp
@@ -13,7 +13,7 @@
(cffi:foreign-free (stream-output-buffer stream))
(setf (stream-output-buffer stream) nil))
-(defmethod stream-flush-output-buffer ((stream unistd-output-stream))
+(defmethod stream-flush-output ((stream unistd-output-stream))
(let ((buffer (stream-output-buffer stream)))
(let* ((fd (stream-fd stream))
(index (stream-output-index stream))