I guess each time you should create a new instance of writer. Cause It&#39;s a pointer to a specific memory address, your loop will keep on rewriting into the same memory space, I&#39;m afraid. Maybe I was wrong, but it&#39;s good to try it out.<br>Best wishes,<br>Cheng Qian<br><br>Sent from my HTC<br><br>----- Reply message -----<br>From: &quot;Xiaopeng Yang&quot; &lt;yxp233@postech.ac.kr&gt;<br>Date: Tue, Aug 3, 2010 10:52<br>Subject: [Insight-users] About SetFileName in for loop<br>To: &quot;&#39;itk&#39;&quot; &lt;Insight-users@itk.org&gt;<br><br>Hi ITK users,<br><br> <br><br>In the fast marching level set method, I tried to program a simulation<br>process for changing parameter &quot;sigma&quot; to get different outputs. Thus I<br>tried for loop. The problem is how to save the different results in<br>different file names. I think I need to change the code of &quot;SetFileName&quot;. If<br>I do not change it, then the later result will replace the previous result<br>automatically. Anyone has any good idea? <br><br> <br><br>for (double sigma = 1.0; sigma &lt;=1.4; sigma += .1) {<br><br> <br><br>...<br><br> <br><br>writer-&gt;SetFileName( &quot;D:/fast_marching_simulation/3D.dcm&quot; );<br><br> <br><br>...<br><br> <br><br>}<br><br> <br><br>Thank you very much!<br><br> <br><br>Xiaopeng<br><br><br><br>