Hi Gool,
I think the best way to stream to disk is to open a file for writing before the processing loop. During the processing loop I would write to this open handle. Once the loop is terminated I would then close the file. Try using the example code I attached and adding the file writing.
What problems are you facing? I might be able to help you more specifically if you could tell me which part of the stream to disk process you are having troubles with. Have a good day.
Ron