Changed it to write one line at a time. Sort problem with large files
Added more debug printouts
Added a check that only allow a thread count between 1 and 1000 threads