Complete the `write-data` utility implementation