Here’s a commented script on how to do it. The read/write commands can act up at times…
--First we set the path to the file
set thePath to (path to desktop as string) & "Yar.txt"
--to write something to a file, we need to open it with write permission
set theOpenFile to open for access thePath with write permission
--now we read the file to get the number stored in it
set theNum to read theOpenFile
--now we set it to a number
set theNum to theNum as number
--now we add 1 to that number
set theNum to theNum + 1
--now we erase the contents of the file
set eof theOpenFile to 0
--now we write the number to the file
write (theNum as string) to theOpenFile
--now we close access
close access theOpenFile
Just replace “yar.txt” with whatever the name of your file is.
Of course, if your file is not at your desktop, then you could set thePath to a path (i.e. “Users:Joe:Desktop:”)