Ensure file is closed by using with statement