Continue output redirection on the same line?

I have

for i in 1 2 3 4
do
  echo $i >> test.txt
done

test.txt contains ...

1
2
3
4

But I want it to contain ...

1234

Any suggestions?

How about:

line=""
for i in 1 2 3 4
do
  line=$line$i
done
echo $line >> test.txt

You can add a \c to the end of echo.

echo "$i\c" >> test.txt

Or even simpler (tested on bash and zsh):

printf "%d" {1..4} > file

Kind regards
Chris