Hi, so the writeToFile function is only for the purpose of writing ITensor objects as binary data. So the odd output you're seeing is raw binary reinterpreted by your text editor as ascii data (even though it's not ascii data).
If you want to write data in ascii to a file, I'd recommend writing a loop over the data you want to save and inside the loop, use the printfln function. Here is an example:
auto i = Index("i",3);
auto j = Index("j",3);
auto k = Index("k",3);
auto T = ITensor(i,j,k);
randomize(T);
PrintData(T);
std::ofstream of("of.dat");
for(auto ni : range1(i.m()))
for(auto nj : range1(j.m()))
for(auto nk : range1(k.m()))
{
printfln(of,"%d %d %d %.12f",ni,nj,nk,T.real(i(ni),j(nj),k(nk)));
}
of.close();