I used 2D array in order to solve the problem, but it looks like some data are written in the wrong column. I pass the data to couple of 2D array, then do something like that

PHP Code:

ofOutputFile
<<data[i][j
There are two problems with that, since the datat will be keep writing to the file, I simply use a constant length for testing only. Second, I have not been able to prevent some of the data written to the wrong column.

Since the data are written from different thread (different function), I think I have also a problme to figure out when to put a carriage return like

PHP Code:

outputFile
<<endl
;