When I use \"cat test.file\", it will show
1 2 3 4
When I use the Bash file,
cat test.file | while read data do e
Actually, if you don't supply an argument to the "read" call, read will set a default variable called $REPLY which will preserve whitespace. So you can just do this:
$ cat test.file | while read; do echo "$REPLY"; done