Adding code block to close files automatically