Added the ability to write to a file with a name that is supplied in the paramaters.