diff --git a/common/source/java/ch/systemsx/cisd/common/filesystem/tar/Tar.java b/common/source/java/ch/systemsx/cisd/common/filesystem/tar/Tar.java
index 82f5f4f26bbd0af8b0e819c7fc5069d921bb9dbe..6383dfd4d3d8857825df9c6b1c9e0259d8794d6a 100644
--- a/common/source/java/ch/systemsx/cisd/common/filesystem/tar/Tar.java
+++ b/common/source/java/ch/systemsx/cisd/common/filesystem/tar/Tar.java
@@ -157,11 +157,16 @@ public class Tar implements Closeable
             entry.setGroupName(groupname);
         }
         out.putArchiveEntry(entry);
-        if (input != null)
+        try
         {
-            IOUtils.copyLarge(input, out);
+            if (input != null)
+            {
+                IOUtils.copyLarge(input, out);
+            }
+        } finally
+        {
+            out.closeArchiveEntry();
         }
-        out.closeArchiveEntry();
     }
 
     @Override