diff --git a/medialist.php b/medialist.php
index <HASH>..<HASH> 100644
--- a/medialist.php
+++ b/medialist.php
@@ -298,7 +298,7 @@ if ($search) {
 			}
 			echo '</td></tr></table>';
 			echo '</td>';
-			if ((++$n) % $columns == 0) {
+			if ((++$n) % $columns == 0 && $n < $count) {
 				echo '</tr><tr>';
 			}
 		} // end media loop
Fix: W3C validation error - Row (n) of a row group established by a tbody element has no cells beginning on it.