My intent is to simply fetch a text file from a website and save it to a file. In order to accomplish this I tried this
function loadText() local path = system.pathForFile( "question.txt", system.ResourceDirectory ) local myFile = io.open( path, "w+b" ) http.request{ url = "http://filesmelt.com/dl/question.txt", sink = ltn12.sink.file(myFile), } print(myFile) end
However all it prints to the terminal is
file <closed>
How could I have myFile store the same text as the downloaded .txt and how could I print that text in myFile?
Thank you, if you have any questions or need me to clarify I gladly will!
(Writing this at 4 AM, I probably sound quite foolish)