Read lines from file and write to RTF using Java

I am trying to read a file and write its contents to a Rich Text field using java. I’m getting “Variant does not contain a container”. Note that the contents of the file is quite large:

FileReader fr = new FileReader(“c:\data.xml”);

LineNumberReader lr = new LineNumberReader(fr);

String str;

RichTextItem body = doc.createRichTextItem(“ReturnValue”);

body.appendText(“Contents shown below:”);

while((str = lr.readLine()) != null)

{

body.addNewLine(1);

body.appendText(str);

}