added multiprocessing setup and write of segments., segments are now close at the end of each chunk