Suppose I have a simple loop
dat=Table["i",{i,1,10}];
Now once the run is finished, I can store the data using
Export["dat.txt",dat]
It works perfectly. However suppose I have a bigger loop with complicated evaluations which takes long time to complete. And I need to use the output upto i=5 before the run is complete. What I mean is that data should be stored in "dat.txt", when i=1 is complete. Then in the next line the file includes the output for i=2. This helps me to use the output file even if some problem related to computer hang problem appears and the code finishes prematurely.
Can someone enlighten me regarding the method I should use for that?