Only write debug messages if descriptor is set

fflush() flushes all open descriptors in case NULL is passed as argument. This patch prevents calls to fflush in case debug file descriptor is not initialized.

See also: https://trac.transmissionbt.com/ticket/4531.