CloseFile in Delphi DLL not Closing File till Dll Unloads when called from VB

Hi,

I wrote a DLL using Delphi that gives multiple programs(VB) the ability
to Write out to a common Memo Control, and log the data to a text
file.  The VB App was getting too large, and needed to be broken
up into multiple executables, but all apps still need to write to the
same log.
The DLL loads a memo control, and supplies functions to write to
the memo.  I'm using AssignFile, OpenFile, Append, and CloseFile for
the Text File writes.  However, the file does not get closed after
the CloseFile is issued.  The file closes when the VB App finishes
and the DLL unloads.  However, If I drive this DLL via a Delphi
App, The file closes with the CloseFile. I ran WinProbe to determine
this
and also by trying to delete the file from WinFile, after the close
happened,
but the DLL still loaded.

I stripped the DLL down to just write a couple of lines and close
the file to rule out other routines.

Anyways, I'm stumped.  Any help would be appreciated.  Snippets of
the DLL, VB app and Delphi app Follow...

-----------------------------------------------------------------------

Delphi DLL Code:  

Interface

  function  WriteLog(UserFrom:PChar):Boolean; export;

Implementation

  function  WriteLog(UserFrom:PChar):Boolean;
  var
   StatFile:String;            {Name of Daily Stats File}
   PStatFile:TextFile;         {StatFile Pointer}
  begin
     StatFile:='z:\oeai\logs\testx.fle';
     AssignFile(PStatFile,StatFile);
     Append(PStatFile);                      {Open for output}
     Writeln(PStatFile,IntToStr(DailyOEC));  {Completions}
     Writeln(PStatFile,IntToStr(DailyOEA));  {Rejects}
     CloseFile(PStatFile);
  end;

-----------------------------------------------------------------------

Delphi Calling Code:  (File closes properly, Calling app need not
close)

  implementation

  function WriteLog(p:PChar): Boolean;
           far; external 'OELOG';
  .
  .
  procedure TForm1.Button1Click(Sender: TObject);
  begin
   if WriteLog('HELLO') then exit;
  end;

-----------------------------------------------------------------------

VB calling Code:  (File remains open until DLL closed)

  Declare Function WriteLog Lib "OELOG.DLL" (ByVal UserID As String) As
Integer
  .
  .

  Sub Command1_Click ()
   tRc% = WriteLog(Environ$("USERID"))
  End Sub

Thanx,
Bob Feller

Compuserve: 70403,2427
Internet:   fel...@ix.netcom.com