Filendir allows you to write a file and create the directories found in its path if needed.
github.com/AoDev/Filendir
AoDev/Filendir