write correct file