add file-write function