Just place an echo before your sed command to see where n why you are going wrong.
One way to go, using the sed editor is:
# assuming default IFS
## based on Kusalananda's observations
set -f ;# disable globbing
list="2 5 7 10"
for i in $list;do
echo "${i}p"
done | sed -nf - longText.txt
## or per K.Kusalanda method has a bug in it
## for empty list it generates wrong output
# printf '%sp\n' $list | sed -nf - longTextlonxt.txt