fixing write.js