SETSTAMP(filename,newdate,newtime)
if SETSTAMP(filename,newdate,newtime) then
begin
........
end
to see if the file is locked. and wait till it is released. but in a sense you are making the file be your semaphore.
I would rather use events, send email, create separate files for each connection.
afterward at the end of the have a processing that will combine the files.