In a sense it's hard to explain it better than the link you provided :) But I guess a concrete example would be illustrative.
Let us assume our data takes values f(x,y,z) = x+y+z, and we have a grid of 5x5x5 values, positioned at x=(1,2,3,4,5), y=(10,20,30,40,50), z=(100,200,300,400,500), then the Cube file header will look like this:
CUBE FILE.
OUTER LOOP: X, MIDDLE LOOP: Y, INNER LOOP: Z
0 1.000000 10.00000 100.0000
5 1.000000 0.000000 0.000000
5 0.000000 10.00000 0.000000
5 0.000000 0.000000 100.0000
This indicates that we have an origin at (1,10,100) (the first point) and the spacing between points in X is 1, in Y it is 10, and in Z it is 100. (The zero on the 3rd line is the number of atoms, we don't use that feature in our Cube files.)
(I cannot guarantee this file format is 100.0% correct with respect to columns and whitespace, I don't know how sensitive Cube file readers are regarding that, or if it's mandated by the format that you must have the data with a certain number of decimals etc.)
Next comes the data. With our carefully designed data set it becomes easy to see how the points are arranged ;)
111 211 311 411 511
121 221 321 421 521
131 231 331 431 531
141 241 341 441 541
151 251 351 451 551
112 212 312 412 512
122 222 322 422 522
132 232 332 432 532
142 242 342 442 542
152 252 352 452 552
113 213 313 413 513
...
In a real cube file you will for sure see scientific notation (%e) like 1.00000e+02 instead of the %g format (100) used here. The line breaks are not too important, but can be inserted after 5 or 6 columns to not get too wide lines (normally you want to keep it within 80 characters, for historical reasons). In the example above I have made line breaks each time the Y coordinate changes, for clarity.
The algorithm (which is described in detail at the page you linked to) is that we pick the first X point, the first Y point, then loop over Z, then the next Y point (still first X point), loop over Z, then next Y point until no more, then next X point, and loop over Y (and over Z for each Y) again.
It might be easiest to reverse engineer the x,y,z values.
If I may make a dummy file instead, with header
0 0.0 0.0 0.0
5 0.2 0.1 0.0
5 0.2 -0.1 0.0
12 0.0 0.0 0.3
then we have 12 data points with
x = 0.0, y = 0.0, z = 0, 0.3, 0.6, ...
Then 12 data points with
x = 0.2, y = -0.1, z = 0, 0.3, 0.6, ...
Then 12 data points with
x = 0.4, y = -0.2, z = 0, 0.3, 0.6, ...
and so on (increasing x by 0.2 and y by -0.1 for each block of 12)
After 60 data points, we move to
x = 0.2, y = 0.1, z = 0, 0.3, 0.6, ... (12 points)
x = 0.4, y = 0.0, z = 0, 0.3, 0.6, ... (12 points)
x = 0.6, y = -0.1, z = 0, 0.3, 0.6, ... (12 points)
and so on (again increasing x by 0.2 and y by -0.1 for each block of 12)
After another 60 data points, we move to
x = 0.4, y = 0.2, z = 0, 0.3, 0.6, ... (12 points)
x = 0.6, y = 0.1, z = 0, 0.3, 0.6, ... (12 points)
x = 0.8, y = 0.0, z = 0, 0.3, 0.6, ... (12 points)
and so on.
I have attached 2 codes, one which prints the x,y,z coordinates for the points in my dummy example (cube_rev_eng_1.py), and another which does it for your header (cube_rev_eng_2.py).
WARNING: the second code generates a lot of output, you will want to pipe the output to a file!
Finally, I attach a general tool (cube_rev_eng.py) which can read a general Cube file (well, at least those produced by ATK) and print the values in the following format:
X Y Z value
Again, this generates a lot of output!