In each iteration of the for loop, you are inserting data in a variable called initialised array (that remains the same during the complete process) and sending it to a variable called output array.
Imagine that initialised array is the following: [0,0,0,0].
In iteration 1 you want to replace element 1 by 3, so you put [0,3,0,0] in output array and initialised array remains [0,0,0,0].
In iteration 2 you want to replace element 2 by 5, so you put [0,0,5,0] in output array and initialised array remains [0,0,0,0], and so on, so in the end you will only have the values of the last iteration.
If you realy want to do things that way, replace output array by a variable to initialised array, but again, the shift registers are a much better way to do that.
Hope this helps,
Paulo