have a function which can call a function inside prolog and capture outut, however does not print until prolog is stopped