To create an infinite desert world maybe there is some way to port a modified pc world to pe, but i'm not sure. To run a function or anything only the first time a world is loaded you can check with newLevel if a file exist in the current world folder, and if not run the command and create the specific file. I usually use 2 functions to read and save data in mcpe, both uses the android java api, which you can also use to create graphic stuff and show a thirst bar, you can find all the documentations online.
Here you can find a lot of MODPE tempates, included the function for saving and reading files
Soooooo how does the read file thing work? I pretty much copy and pasted both of those functions under a newLevel, and then inside the read was an if saying if it read the file, then clientMessage of "working" just so I know. And then it was an else, do the thing and create the file, with a clientMessage of "file made!" And every time, Id get "file made!" So, I am quite confused.