Now works on all file loops, and combines into one file per file type, with proper XML formatting and pretty-print.