routine to write profile