Add write() and output file