define and use closeAndRename() after last write of xml dump file; convert from popen...