I’d suggest logging to a discord channel via webhook over a text file, but that’s just my personal opinion.
But what you’re looking for is io.write()
Here is more information on how to read and write files in lua: