writing file as seperate step