Put only starts after execute?

I would like to run my gams file gamsfile.gms several times for different values a and b. For this, I created a file which states

set 
  a /boat, house, car/
  b /y1*y8/;
file myfile /input.inc/; 
loop((a,b),
  put myfile;
  put "$setglobal value_a " a.tl /;
  put "$setglobal value_b " b.tl /;
  putclose myfile;
  execute 'GAMS gamsfile.gms o=gamsfile.lst'
);

gamsfile.gms starts with

$INCLUDE input.inc
$gdxIn data_%value_a%_%value_b%.gdx

However, when I let this run, GAMS seems to create the input.inc file only after the execution of gamsfile.gms has already started - so gamsfile.lst reports that there was no input.inc file that it could open, while input.inc appears in the folder right afterwards.
If I run it again, gams can open the include file (since it still exists frm the previous run), but only with the last values that were written on there.
I don’t understand this, as everything should run in run time. Does anyone have an idea?

@Tatjana ,

I cannot reproduce the behavior you describe. I created a small self contained example (I commented the $gdxin … but added some $LOG … to write to the log which GDX file should be read).

$onEchoV > gamsfile.gms
$INCLUDE input.inc
$LOG ### read GDX File: data_%value_a%_%value_b%.gdx
*$gdxIn data_%value_a%_%value_b%.gdx
$offEcho

set 
  a /boat, house, car/
  b /y1*y8/;
file myfile /input.inc/; 
loop((a,b),
  put myfile;
  put "$setglobal value_a " a.tl /;
  put "$setglobal value_b " b.tl /;
  putclose myfile;
  execute 'GAMS gamsfile.gms o=gamsfile.lst'
);

In the lst of the main file I get

[...]
### read GDX File: data_boat_y1.gdx
[...]
### read GDX File: data_boat_y2.gdx
[...]
### read GDX File: data_boat_y3.gdx
[...]

So this looks all good and in gamsfile.lst the inc file is found as expected. If the problem persists, please share log and lst files and everything required to reproduce exactly what you are doing.

Fred