added support for writing data to files