Fixes
diff --git a/gds_to_lef_gds_mag.py b/gds_to_lef_gds_mag.py
index ef90af0..3a2cf31 100755
--- a/gds_to_lef_gds_mag.py
+++ b/gds_to_lef_gds_mag.py
@@ -857,12 +857,18 @@
     prepend_copyright(lef_out_file)
 
 
-def rewrite_out_mag(mag_in_file, mag_out_file):
+def rewrite_out_mag(mag_in_file, mag_out_file=None):
+    if mag_out_file is None:
+        mag_out_file = mag_in_file
+
     with open(mag_in_file, 'r') as f:
         contents = f.read()
 
+    mag_base = os.path.basename(mag_out_file)
+    gds_base = mag_base.replace('.mag', '.gds')
+
     contents = re.sub('timestamp [0-9]+', 'timestamp 0', contents)
-    contents = re.sub('string GDS_FILE .*', 'string GDS_FILE '+mag_file.replace('.mag', '.gds'), contents)
+    contents = re.sub('string GDS_FILE .*', 'string GDS_FILE '+gds_base, contents)
 
     with open(mag_out_file, 'w') as f:
         f.write(contents)