Index: trunk/ppMerge/src/ppMergeReadChunk.c
===================================================================
--- trunk/ppMerge/src/ppMergeReadChunk.c	(revision 24798)
+++ trunk/ppMerge/src/ppMergeReadChunk.c	(revision 35687)
@@ -24,5 +24,5 @@
                                               "INPUTS.VARIANCES");// Do we have variances?
     int rows = psMetadataLookupS32(NULL, config->arguments, "ROWS"); // Number of rows to read per chunk
-
+    int rejectedInputs = 0;
     // select an available fileGroup
     while (1) {
@@ -73,4 +73,5 @@
 			psWarning ("skipping video cell (1: %ld)", (long) pthread_self());
 			inRO->process = false;
+			rejectedInputs++;
 			continue;
 		    }
@@ -86,4 +87,5 @@
 			psWarning ("skipping video cell (2: %ld)", (long) pthread_self());
 			inRO->process = false;
+			rejectedInputs++;
 			continue;
 		    }
@@ -94,4 +96,5 @@
 		    psWarning ("skipping video cell (3: %ld)", (long) pthread_self());
 		    inRO->process = false;
+		    rejectedInputs++;
 		    continue;
 		}
@@ -119,12 +122,20 @@
                     }
                 }
-
+		
 		// fprintf (stderr, "%lx, %lx, %lx\n", (long int) inRO->image, (long int) inRO->mask, (long int) inRO->variance);
-
-                if (!keepReading) {
-                    return NULL;
-                }
+		if (!keepReading) {
+		  return NULL;
+		}
+		
+		
             }
-
+	    psLogMsg("ppMerge",PS_LOG_INFO,"%d %ld %d %d %d",
+		     j,readouts->n,rejectedInputs,fileGroup->read,fileGroup->busy);
+	    if (rejectedInputs >= readouts->n) {
+	      fileGroup->read = false;
+	      fileGroup->busy = false;
+	      return NULL;
+	    }
+	    
             fileGroup->read = fileGroup->busy = true;
             return fileGroup;
