diff --git a/src/Http/Middleware/LaravelCaffeineDripMiddleware.php b/src/Http/Middleware/LaravelCaffeineDripMiddleware.php
index <HASH>..<HASH> 100644
--- a/src/Http/Middleware/LaravelCaffeineDripMiddleware.php
+++ b/src/Http/Middleware/LaravelCaffeineDripMiddleware.php
@@ -47,6 +47,13 @@ class LaravelCaffeineDripMiddleware
             "{$dripper->html}</body>",
             $content
         );
+
+        $content = preg_replace(
+            '/(<\/body\>?|<\/html\>?|\Z)/',
+            $dripper->html . '$1',
+            $content,
+            1
+        );
         $original = $response->original;
         $response->setContent($content);
         $response->original = $original;
Added functionality to account for missing body or html closing tags, thanks @tontonsb