don't use the number of written bytes as indicator if streamCopy() was successful

Don't use the number of written bytes as indicator if streamCopy() was successful. Instead check if fwrite() returns the number of bytes or false.

This fixes issue #1851 and other potential errors if we streamCopy empty files.