in reply to Re^2: text files are printed after the end of second module
in thread text files are printed after the end of second module

At least in the code you have shown so far, you never call the subroutine.

  • Comment on Re^3: text files are printed after the end of second module