Change save function

fprintf() is not correct now.