utility for handling tmp file streams