updated write function

removed an extra 'cout' and added some clarification.