Sed and white spaced string problem

Consider a string with white space "abc 123"
string="abc 123"
echo $string
abc 123
sed "s/$string/$string 456/" file
abc 123 456

cat file
abc 123

OK for now, but if you put this one in a shell script

it gives the result:
abc 456 123

somehow string end in first white space ??

any idea why this happen ?

The IFS default value is white space. When a record comes out of a file as abc 123 it is seen as two fields.

Since you didn't specify what gave the problem I can't be more explicit.

what shell do you use?
it works allright for me using bash.

I tried sh and ksh , but I do not have bash in my environment. Thx.

---------- Post updated at 12:37 AM ---------- Previous update was at 12:32 AM ----------

So , in command line it is working shell is Posix, but inside my script like below , do I have to put IFS to another seperartor ?? :

#!/bin/sh
cat testfile > test2file
line2=" 456"
cat test2file |grep -i kernel |grep -v notsc | while read line
do
sed "s/$line/$line $line2/" test2file > test3file
cp test3file test2file
done

---------- Post updated at 03:06 PM ---------- Previous update was at 12:37 AM ----------

if I perform sed operation in command line there is no problem ??:

igui01# line1="kernel 600"
igui01# echo $line1
kernel 600
igui01# cat testfile
12345
678910
abcdefg
kernel
kernel bosluk notsc
kernel 123
kernel 600
kernel mevcut notsc
igui01# sed "s/$line1/$line1 notsc/1" testfile
12345
678910
abcdefg
kernel
kernel bosluk notsc
kernel 123
kernel 600 notsc
kernel mevcut notsc

I wonder what is root cause of a string in sed (in script)
split up to white space like this :
kernel 600 will turn to kernel ???