in reply to Re^2: text files are printed after the end of second modulein 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.