write the rewritten datalog directly to the file system (this should save some memory)