add debug-print to write-file