Is your issue about just syntax?
for part in $text; do
echo "xX${part}Xx"
done
In bash, this loops over each word in a variable. If you want each line, you'll need to use a while read loop instead.
while read -r line; do
echo "xX${line}Xx"
done <<< "$text"