'Bash issue with unexpected token

The script below seems to work when I run it on its own in vscode it says literal carriage return on the second and third line.

When I put it into a larger script I get this issue

./script.sh: line 64: syntax error near unexpected token `newline'
./script.sh: line 64: `ipv6address=$(hostname -I | cut -d " " -f 2)'

Can any one advise please

#!/bin/bash
ipv6address=$(hostname -I | cut -d " " -f 2)
tee -a <<EOF >/dev/null "$HOME"/ipv6
[network]
# replace the ip with yours
routable_ip ="$ipv6address"
EOF


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source