Corrected to write also last thread. Added output messages. Arranged input folder