Fixed bug with write-file.