Made changes to write() methods.