If I understand the issue correctly, I think the problem is that your where clause will filter out the value that you're looking for: if "IN005" doesn't exist then it will never get to the return clause.
instead you should not have a where clause and do the check in the return:
for $family in doc("gedcom.xml") /*/FamilyRec
return if($family/Child/Link[@Ref = "IN005"]) then "NotEmpty" else "Empty"