You say, "On the web server the file is created but no data is written." ... which file? upload.log? c:\upload\$client.txt? Or $file? It looks like you don't close the filehandle to $file ... Just a guess.
The c:\upload\$client.txt file is created but no data is written. I have the close(FH) at the end which is the c:\upload\$client.txt filehandle.
The upload.log file is written and saved without any problems. In response to the first reply the error.log file says "Premature end of script headers."