change writing file from Sync to Async