INDY Writing to a file disconnect TCP client


Did someone ever experience connection problem with a TCP connection
while trying to write to a file ?

If I uncomment the next block, the WriteLn still works, but the client
will be soon disconnected.

   //FILE* file = fopen("Seat.txt","w");
   //if(file!=NULL) {
   //   WriteLine(file,Seat);
   //   fclose(file);
   //   }

Commented, all works fine.
Quite strange.