first implementation of data-to-file