The following code snippet appears to comply with the BIFF rules regarding working with only one file at a time. However, for FileCount = 3, it creates only one proper file with all data written (for i = 1). Two others are created with the proper names and in the proper place, but they are empty, 4-byte files containing only the last 4 bytes of a proper file (0A-00-00-00). Any ideas what I am doing wrong?

FOR i = 1 TO FileCount
'---Create the output file
BIFF_CreateFile (APP_ScriptPath & OutFileName & "-" & i & ".xls")
'---Create the header string
HeaderStr = "File " & OutFileName & "-" & i & ".xls"
HeaderStr += " created on " & MyDateStr
HeaderStr += " at" & TIME$
'---Write out the data
BIFF_WriteText (HeaderStr, 1, 1)
BIFF_WriteText (StrBuffer(i), 3, 1)
BIFF_CloseFile
NEXT