on *:disconnect: {
if ($isfile(file.txt)){ write -c file.txt }
}
This will clear the file for you when you disconnect. Or you can use it when you connect.
on *:connect: {
if ($isfile(file.txt)){ write -c file.txt }
}
Now you dont need to delete the file every time you disconnect from the server.