--- ./libdnf/utils/utils.cpp_orig	2021-03-24 07:39:46 +0000
+++ ./libdnf/utils/utils.cpp	2021-03-25 08:12:19 +0000
@@ -288,27 +288,30 @@
         throw std::runtime_error(tfm::format("Error opening %s: %s", outPath, strerror(err)));
     }
     char buf[4096];
+    #if 0
     while (auto readBytes = fread(buf, 1, sizeof(buf), inFile)) {
+    #endif
+    while (auto readBytes = gzread(fd_save_gzf, buf, sizeof(buf))) {
         auto writtenBytes = write(outFd, buf, readBytes);
         if (writtenBytes == -1) {
             int err = errno;
             close(outFd);
-            fclose(inFile);
+            gzclose(fd_save_gzf);
             throw std::runtime_error(tfm::format("Error writing to %s: %s", outPath, strerror(err)));
         }
         if (writtenBytes != static_cast<int>(readBytes)) {
             close(outFd);
-            fclose(inFile);
+            gzclose(fd_save_gzf);
             throw std::runtime_error(tfm::format("Unknown error while writing to %s", outPath));
         }
     }
-    if (!feof(inFile)) {
+    if (!gzeof(fd_save_gzf)) {
         close(outFd);
-        fclose(inFile);
+        gzclose(fd_save_gzf);
         throw std::runtime_error(tfm::format("Unknown error while reading %s", inPath));
     }
     close(outFd);
-    fclose(inFile);
+    gzclose(fd_save_gzf);
 }
 
 }
