Question: Use ** rather than ^ when printing to file

I am writing a matrix to file where each matrix element is placed on a new line. An example of such code:

restart:
HH:=Matrix([[x**2,x**z,z**12],[2*x,5**y,6**1]]):
filenameHH:=fopen("test.txt",WRITE,TEXT):

nRow,nCol :=LinearAlgebra[Dimension](HH);
for i from 1 to nRow do
   for j from 1 to nCol do
      fprintf(filenameHH,"%a\n",HH[i,j]):
   od:
od:
fclose(filenameHH):

When this is printed to file, it will print as the power sign ^ regardless of the input it is given. This particular output file will be read in by another language, and due to this the power symbol "^" is not desired, but instead " ** ". By converting the matrix into a string format and applying string operations, this can be done; but is there a simpler way to do it?

-Yeti

Please Wait...