>In other words, I needed to create a file for each different client and each different carrier. If I'm using scan/endscan, I have to repeat the code after the scan to create file for the last set of client/carrier. Originally I added a check in scan itself and was surpised, that my eof() or reccount() = recno() didn't work. But then I realized, that my logic dictates one additional loop, that I was able to achieve with for loop.
You could create a function to do that
local oldKey
OldKey = null
scan all for .... while ....
if( !isnull(OldKey) and (OldKey <> NewKey) )
=makeTheFile()
endif
OldKey = NewKey
endscan
if( !isnull(OldKey() )
=makeTheFile()
endif
Gregory