Although by the word your question doesn't exactly make sense, I assume you mean the following:
1 You have successfully made your software write a plain text file.
2 Your software failed writing a Microsoft Word document in a way that MS Word could open it.
The problem is that a Word document is a very complex thing. It is able to store format information for almost anything you can ever think of putting into a series of books. Additionally, there is no publically available specification AFAIK.
But there are
specialized classes[
^] for dealing with Word documents. Using them may need Microsoft Word to be installed on the target machine.