I have it in the EVENT ADDON LOADED , which is the way it works in other addons I have done. I even took one trial to create it later via chat command to see if it was too early in addon loaded. I'll have to re-recheck the folder naming when I get home. I was also thinking, could it be issue of wrong kind of line endings in the .txt. Also the function seems to work otherwise since a table it returns works further in the code, without causing nil accessing problems.. The file just doesn't get created.
I recreated the .txt file from the beginning, and now it works. The only difference I seem to have is that now there is linebreak in the end of the file, while earlier it ended in the line that contained the .lua file to be loaded... No idea if that was the problem, or if there was some thing else mystically broken.