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.