added the impwrite function.