What I'm trying to do is have my function start a new m-file and add text to it, but without saving it.
fopen directly saves the file and edit does not let me append content without typing it in the script myself.
The solution could look something like:
contents = 'Hello world!';
Where contents is to be printed in the file without saving it. I know that edit only takes filenames for inputs but this is just for illustration.