Solved it with this: https://stackoverflow.com/a/56467627/12499839
Just made a small change in atomic_list_concat():
print_matrix([]).
print_matrix([Row|Rows]):-
atomic_list_concat(Row, ' ' , TRow),
writeln(TRow),
print_matrix(Rows).
CLICK HERE to find out more related problems solutions.