I've never had this issue before. My code will create the file and also output anything to terminal. But if I change the output from terminal to file, it does nothing. For example, this line
write(*,*) "ist1, ist2 =",ist1,ist2
outputs my two indices in every loop iteration. But...