I'm having trouble with writing to a file. Here is my code:
File("test.txt").printWriter().use { out ->
out.println("First line")
out.println("Second line")
I've looked that the answers at How do I write to a file in Kotlin? but they don't work; gradle builds and runs but test.txt
stays empty. I've also checked the Kotlin documentation but I can't find anything.
Thanks!
Edit: If I put the full path of the file then it works.