add ability to write to a file

THIS IS CURRENTLY A HUGE HACK