Output Generated Script as a File

I am trying to develop a sort of extension for unity that will help manage in game events. My approach so far has been to try and make a script that will go into the editor folder and use Unity Editor classes. Part of what needs to happen is that I need to generate some scripts to attach to the gameObjects based on Input to the extension gui, however so far I have been unable to find a way to write to any script files for use as assets. I am able to create new blank script files by using:

var EventManager = new GameObject("Event Manager");

EVS = EventManager.AddComponent(MonoBehaviour);

AssetDatabase.CreateAsset(EVS,"Assets/Scripts/EventManagerScript.js");

but I can’t write to them. It feels like there should be an easy way to do this but so far no luck :expressionless:
I was thinking that maybe there was something in UnityEditorInternal that I could use, but I have been unable to find any documentation or even a list of functions for it.

As I thought there was a very simple solution. Previously I had been trying to write the files using only Unity functions and such. However I have since found out (although I feel pretty dumb for not realizing this before since Unity scripting is based on Mono) that I can use .NET Classes such as System.IO.File. I realize that this is probably blatantly obvious to many of you out there. So anyways by doing so I can now write to files whatever I so desire with this:

static function write(path : String, data : String){

System.IO.File.WriteAllText(path,data);

}

Also thankfully all paths for System.IO.File are relative to project just like for Unity classes like AssetDatabase.
doh!