use blocks to automatically close file