Each recursed call opens (and likely fails in doing so) the same file on-disk with a new file object. That isn't going to work. You need to open the file outside of all of this and pass it as a reference parameter
template <class elemType>
void bSearchTreeType<elemType>::writeFileTree(std::ostream& os, binaryTreeNode<elemType> *p) const
{
if (p != NULL)
{
writeFileTree(os, p->llink);
os << p->info << '\n';
writeFileTree(os, p->rlink);
}
}
Make the caller open and close the file. And your node pointers should (likely) be const
parameters, btw.