Once you are done working with a file, close the file. Not closing the file is considered a resource leak, which can lead to issues until you restart your computer. Closing a file is simple, just call the close member function on the file handle. For example:
local file = io.open("data.txt", "w")
file:write("foo", " ")
file:write("bar")
file:close() -- THIS IS NEW! Don't forget to close!