in reply to Re^2: Client-Server app
in thread Client-Server app

Just checking if you meant Un-Commenting the open/print to append to $output would cause the program to break.

I suspect that multiple threads appending to a file may be giving you trouble.

I suggest starting a separate thread to collect the output, and append it to a file in a single thread.
You can use Thread::Queue to pass data to the collector thread.

                Memory fault   --   brain fried