The problem can arise when the loop is called elsewhere (where it may outlive the FileOut streams.). I guess it is simply enough to warn the users about this in the docs.
Well, I have some reservation about the whole api design, but yes, this case I would say it is ok and has to be documented.