overcome problem in writing file