writes data to files