I need help with a small program to arrange a data file:

This is the data file:

data
A
B
C
D
data
1
2
3
4
data
D
E
F
G
data
5
6
7
8

I need the data to be arrange as shown below:

data A B C D
data 1 2 3 4
data D E F G
data 5 6 7 8

Thanks!