Require or include would pull the file directly into place wherever you used the require or include statement and it wouldn't pull things into a variable like you're doing there. For what it looks like you're doing that looks like a decent way to handle it.
Please understand that using require_once() will be the best option for you in this case. require_once() will only include the file 1 time, and if it has previously been included (for some reason) then it will throw a fatal warning, alerting you to the line it was previously included in, so you can remove it.
This ensures that the same file doesnt get included twice.
Also, using require_once() instead of fopen, is MUCH faster, as require_once() uses highly optimzed C code, from the php core function library to include your files.
Thank you. But, I can't use require_once() nor require due to the way the forum is designed. It has templates in tpl files. And it replaces place holders like I did above.