Hi, soonix, thank you for the comments.
Could you explain more? What output buffer do you mean? A buffer allocated by print() function?
Wired thing is that I monitor the execution of the script through a putty terminal and find it hangs there for a long while on 2/14 and leave it there. When I am back to it on 2/15 I find it still hangs. So I connect to the machine through the console. When I am in the console it resumes suddenly. The machine configuration is: IBM server -> InReach TTY -> terminal.