implementing writeOutput array for every time step