fix bug(num_writes is never under zero because it is unsigned value)

success and failure of apr_file_write should be judged by its return value