diff --git a/lib/modules/Stdio.pmod b/lib/modules/Stdio.pmod
index 4ea39de0334c5a81eb2ba15306d0a3a4d1875fc4..cc9a9b80eef106fc51c64bd1c97177f1b4d3b235 100644
--- a/lib/modules/Stdio.pmod
+++ b/lib/modules/Stdio.pmod
@@ -137,6 +137,10 @@ class File
 
   static void my_read_callback()
   {
+#if defined(__STDIO_DEBUG) && !defined(__NT__)
+    if(!::peek())
+      throw( ({"Read callback with no data to read!\n",backtrace()}) );
+#endif
     string s=::read(8192,1);
     if(s && strlen(s))
     {