set is not a useful
sh command in this context, and you need to avoid having spaces on either side of the equals signs. Also take care to put spaces where you do need them.
Code:
#! /bin/sh
i=0
count=$(wc -l < file2.txt)
while [ $i -le $count ]
do
i=`expr $i + 3`
head -n $i file2.txt >> file1.txt
done
As such, simply
head -n 3 file2.txt >>file1.txt should do what you want. Or maybe I misunderstand your problem description. Either way, your loop will read from the beginning of
file2.txt on each iteration, which doesn't seem useful.