Please make sure the file gets closed in error cases by using with or try/finally.