adding auto reopen file when write error.