diff --git a/src/dht_proxy_server.cpp b/src/dht_proxy_server.cpp
index 74c571f6489967e70045c652f16a706b5e54a7e1..b87ef9f0d204a7c6747a3f831a47ad263994cabf 100644
--- a/src/dht_proxy_server.cpp
+++ b/src/dht_proxy_server.cpp
@@ -563,10 +563,9 @@ DhtProxyServer::listen(restinio::request_handle_t request,
                 auto jsonVal = value->toJson();
                 if (expired)
                     jsonVal["expired"] = true;
-                auto output = Json::writeString(jsonBuilder_, jsonVal) + "\n";
-                response->append_chunk(output);
-                response->flush();
+                response->append_chunk(Json::writeString(jsonBuilder_, jsonVal) + "\n");
             }
+            response->flush();
             return true;
         });
         return restinio::request_handling_status_t::accepted;