You're echoing the filename, rather than checking its contents. Try something like:
if fgrep '[exclude-XYZ]' -- "$1" >/dev/null; then
:
else
echo "[XYZ]" >> "$1"
fi
Or, as a one-liner:
fgrep '[exclude-XYZ]' -- "$1" >/dev/null || echo '[XYZ]' >> "$1"