Writing logs for group of files and sorting in alphabetic order