in reply to Find and Replace multiple values in a file.

If the problem is buffering and closing the filehandle doesn't solve your problem, try making the filehandle hot. A frequently referenced article on the subject is Suffering from Buffering?

select OUT; $| = 1; print OUT '';