Buffering was definitely an issue. I think I now have a solution. Thanks.
In reply to Re^2: can't write to file from socket (flush) by femerrill in thread can't write to file from socket by femerrill