diff -upr sbase-0.0_orig/cat.c sbase-0.0/cat.c
--- sbase-0.0_orig/cat.c	2011-05-23 02:36:24.000000000 +0100
+++ sbase-0.0/cat.c	2011-05-23 19:49:45.161996425 +0100
@@ -28,7 +28,7 @@ cat(FILE *fp, const char *str)
 	char buf[BUFSIZ];
 	size_t n;
 
-	while((n = fread(buf, 1, sizeof buf, fp)) > 0)
+	while((n = freadeof(buf, 1, sizeof buf, fp)) > 0)
 		if(fwrite(buf, 1, n, stdout) != n)
 			eprintf("<stdout>: write error:");
 	if(ferror(fp))
diff -upr sbase-0.0_orig/tee.c sbase-0.0/tee.c
--- sbase-0.0_orig/tee.c	2011-05-23 02:36:24.000000000 +0100
+++ sbase-0.0/tee.c	2011-05-23 19:48:31.155996455 +0100
@@ -26,7 +26,7 @@ main(int argc, char *argv[])
 		if(!(fps[nfps-1] = fopen(argv[i], aflag ? "a" : "w")))
 			eprintf("fopen %s:", argv[i]);
 	}
-	while((n = fread(buf, 1, sizeof buf, stdin)) > 0)
+	while((n = freadeof(buf, 1, sizeof buf, stdin)) > 0)
 		for(i = 0; i < nfps; i++)
 			if(fwrite(buf, 1, n, fps[i]) != n)
 				eprintf("%s: write error:", buf);
diff -upr sbase-0.0_orig/util.c sbase-0.0/util.c
--- sbase-0.0_orig/util.c	2011-05-23 02:36:24.000000000 +0100
+++ sbase-0.0/util.c	2011-05-23 19:48:01.211996445 +0100
@@ -20,3 +20,11 @@ eprintf(const char *fmt, ...)
 	}
 	exit(EXIT_FAILURE);
 }
+
+size_t
+freadeof(void *buf, size_t one, size_t n, FILE *fp)
+{
+	if(feof(fp))
+		return 0;
+	return fread(buf, one, n, fp);
+}
diff -upr sbase-0.0_orig/util.h sbase-0.0/util.h
--- sbase-0.0_orig/util.h	2011-05-23 02:36:24.000000000 +0100
+++ sbase-0.0/util.h	2011-05-23 19:47:27.983996445 +0100
@@ -1,3 +1,7 @@
 /* See LICENSE file for copyright and license details. */
 
 void eprintf(const char *, ...);
+
+#ifdef _STDIO_H
+size_t freadeof(void *, size_t, size_t, FILE *);
+#endif
