Fixed bad usage of fs.write()