Ah sneaky, found the issue! Thanks alot. All directories had correctly set permissions. I tried to output the .txt file to different directories with no result. Then lastly I figured, maybe I have to set user root; in my nginx.conf to solve this access problem, and voila! It worked. I had a pretty basic nginx.conf and I had no use of having user root; until now when I found out it was a requirement. Thanks for helping me find the issue! Problem solved.