\documentclass[]{article}
\usepackage{tikz}
\usepackage{pgfplotstable}
\usepackage{collcell}
\pgfplotsset{compat=newest}
\begin{document}
\section{In the Document and as outfile - good}
\subsection{Data}
\newwrite\kanaoutfile
\immediate\openout\kanaoutfile=KanaData.txt%
\newcommand{\row}{}% reserv Name
\foreach[count=\y from 0] \Y in {{}, {}, K,S,T,N,H,M,Y,R,W}{%%%
\let\row=\empty% create List
\foreach[count=\x from 0] \X in {{}, A,I,U,E,O,N}{%%
\pgfmathparse{
\y==0 ? (\x==0 ? "yyy" : (\x==6 ? "\X" : "--\X")) :