Saving data inside a loop

Hello,

I have written in FreeFem++ a central differences scheme to the weak formulation of the 2D wave equation in a square. and initialized it with two initial conditions, then I have a loop for the time of the simulation, hence in each time of the simulation t is known and u^n-1 and u^n are given to scheme and u^n+1 is calculated, I wanted to ask, please how can I save the data of u^n and u^n+1 for each time of the simulation in an array or in a file.

Thanks,
Mordechai.