writing file bug fixed