added a method to write individual files out for use elsewhere