dynamic run

Hi MS User,
I wrote a script to run for dynamic as follows:


1. my \$j = 50;

2. for (my \$yPos=0;\$yPos<=301; ++\$yPos) {

3. my \$energy = Modules->Forcite->Dynamics->Run(\$doc);

4. # Save file progress at 50-step increments
if (\$yPos==\$j) {
my \$copyDoc = \$doc->SaveAs("sio2_vsim_grap_AFMstep\$yPos.xsd");
\$j=\$j+50
5. }


6. my \$trajectory = \$Documents{"filename.xtd"}->Trajectory;

7. \$trajectory->Delete;


9. \$wall->Translate(Point(x=> 0, Y =>-0.01,z=>0));
10. }

But It only run once and display the message as follows:

11. Dynamics calculation - The trajectory file '\filename.xtd' already exists.
12. Please ensure that documents created by previous runs are renamed or deleted before running a Forcite calculation in Forcite.Dynamics (function/property "Run") at -e line 40.

How do I run the program as many times as I want? Do the lines 6 and 7 not delete the .xtd file created in the previous run?
Any suggestions will be hearty appreciated.

Thanking you
Laxmi