Firstly, please use [code][/code] tags around code / data
Yes this can be done in awk ... look into the NR variable
As for your script, you have a loop inside a loop so obviously this will take longer than a single loop.
On top of that, you use process substitution of echo to reassign to a variable when you could simply append the variable data:
Code:
out=$(echo $line)
# is just
out=$line
out=$(echo $out $line)
# is just
out="$out $line"
Like the awk solution, why not have a simple counter and each time you reach a particular number of lines read, you append a new line to the data.
Your initial question talks about outputting the data, but your example shows it being written to a new file, in that case build the line as above and simply echo to new file once
you reach counter value.