writing file, debugging