I seem to be failing at making a very simple piece of code work. It seems that it just causes the bot to hang, but I don't know enough to know what I'm doing wrong as I'm operating by example.
Probably because you're telling it to wait for user input (io.stdin:read()). I don't know why you would ever possibly want to ask the user for the filename every time it attempts to harvest something. Get rid of that and just replace it with: