DocumentBuilder Write or DocumentBuilder Writeln is not writing to file

I am trying to write some content in words file

SharedPtr<Document> doc = System::MakeObject<Document>();
SharedPtr<DocumentBuilder> builder = MakeObject<DocumentBuilder>();
System::String protected_file_path(filePath);
builder->Write(protected_file_path);
System::String shadow_file_path(src_directory_path + fileName);
doc->Save(shadow_file_path);

when I open the file, it does not have anything in it. I tried writing some property values like author, it was reflecting those details.
I am using msoffice 2021 professional

@deepanshugarg09 You should pass Document object into the DocumentBuilder constructor:

System::SharedPtr<Document> doc = System::MakeObject<Document>();
System::SharedPtr<DocumentBuilder> builder = System::MakeObject<DocumentBuilder>(doc);