re-organizes output file of sweep_shared_terms