The easiest way to achieve this is to include the Newline character sequence each time you call the write method as follows: file:write("hello\n") or like this: file:write("hello", "\n") . Thus a script for example
file = io.open(test.txt, "a") file:write("hello", "\n") file:write("hello", "\n")
will lead to the desired result:
hello hello
However, there are many other solutions for this (some of them are more elegant than others). For example, when outputting text in Java, there are special methods such as BufferedWriter#newLine() that will do the same in a cleaner way. Therefore, if you are interested in another way to achieve this, I suggest you familiarize yourself with the Lua docs for similar methods / solutions.
Priidu neemre
source share