in reply to formline, undefined format STDOUT

Perhaps write requires that you use format instead of just formline. Read perlform.

Consider using the simpler printf.