You also do not need to have SierspinskiTriangleBuilder save its output to a file, then read that file back in. Ideally, you should create a method in SierspinskiTriangleBuilder that returns the XML as a string that would be saved to a file by the method SierspinskiTriangleBuilder.save(). Then you could use that method here to get the XML as a string without having the need for complex I/O code to build the string yourself.