print sorted result to file