This should always work. Perhaps your write(iow,*) line is not being reached? or there is an error that occurs before the buffer is flushed? Try replacing with write(*,*) just to get output to the screen to make sure you are getting to you line.
But better would be to use gdb to step through your subroutine to see what is happening.