Index: trunk/Ohana/src/imregister/detrend/output.c
===================================================================
--- trunk/Ohana/src/imregister/detrend/output.c	(revision 7)
+++ trunk/Ohana/src/imregister/detrend/output.c	(revision 9)
@@ -49,5 +49,4 @@
 
 int DumpFitsTable (char *filename, DetReg *detdata, Match *match, int Nmatch) {
-# define NL 453
   
   Header header, theader;
@@ -56,5 +55,5 @@
   DetReg *newdata;
   FILE *f;
-  char *startstr, *stopstr, *regstr, line[NL], key[33];
+  char *startstr, *stopstr, *regstr, *line, key[33];
   char *filtstr, *typestr, *ccdstr, *datestr, *p;
   int i;
@@ -105,16 +104,16 @@
   fits_modify (&theader, "TNULL12", "%s", 1, "");
 
-  fits_modify (&theader, "TBNA1",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA2",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA3",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA4",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA5",  "%lf", 1, (float) -2);
-  fits_modify (&theader, "TBNA6",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA7",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA8",  "%s", 1, "NA");
-  fits_modify (&theader, "TBNA9",  "%d", 1, -2);
-  fits_modify (&theader, "TBNA10", "%d", 1, -2);
-  fits_modify (&theader, "TBNA11", "%s", 1, "NA");
-  fits_modify (&theader, "TBNA12", "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN1",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN2",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN3",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN4",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN5",  "%lf", 1, (float) -2);
+  fits_modify (&theader, "TBNAN6",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN7",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN8",  "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN9",  "%d", 1, -2);
+  fits_modify (&theader, "TBNAN10", "%d", 1, -2);
+  fits_modify (&theader, "TBNAN11", "%s", 1, "NA");
+  fits_modify (&theader, "TBNAN12", "%s", 1, "NA");
 
   /* create table, add data values */
@@ -142,10 +141,12 @@
     filtstr  = filterhash[newdata[0].filter];
     ccdstr   = ccds[newdata[0].ccd];
-    snprintf (line, NL, "%32s%20s%20s%20s%7.1f%10s%10s%7s%3d%3d%64s%256s",
-	      key, startstr, stopstr, regstr, newdata[0].exptime,
-	      typestr, filtstr, ccdstr,
-	      newdata[0].Nentry, newdata[0].Norder, 
-	      newdata[0].label, newdata[0].filename);
+
+    line = fits_table_print (&table, key, startstr, stopstr, regstr, 
+			     newdata[0].exptime, typestr, filtstr, ccdstr,
+			     newdata[0].Nentry, newdata[0].Norder, 
+			     newdata[0].label, newdata[0].filename);
+
     fits_add_rows (&table, line, 1, strlen(line));
+    free (line);
     free (startstr);
     free (stopstr);
