diff --git a/wetb/hawc2/htc_file.py b/wetb/hawc2/htc_file.py
index ad5cf45e1cacdb772ea9b6e70f9199d912903f66..54a742a53645cb1425e658c9dcbb62c3c141db3f 100644
--- a/wetb/hawc2/htc_file.py
+++ b/wetb/hawc2/htc_file.py
@@ -83,7 +83,7 @@ class HTCFile(HTCContents, HTCDefaults):
         else:
             self.filename = filename
         # exist_ok does not exist in Python27
-        if not os.path.exists():
+        if not os.path.exists(os.path.dirname(filename)):
             os.makedirs(os.path.dirname(filename))#, exist_ok=True)
         with open(filename, 'w') as fid:
             fid.write(str(self))