fixed multi input file support and fixed bug in outputing non-sorted records