Moved the output part (1) to the end of the loop

Now that the Enqueed read and write calls (6 and 7) are interwined with the
compute kernel, the output function was move to the end of the code in order
to allow overlap between the host and devices subtasks.