You're reading lines, but you're not doing anything with what you read. Try:
#!/bin/sh
while read line
do
printf '%s\n' "$line" | sed 's/<TEST>/FOO/'
done <&0
Also you may want to change the while read line to
while IFS= read -r line || [ -n "$line" ]
to ensure that you are reading everything as cat testfile.txt | sed 's/<TEST>/FOO/' would. See