Use a 'with' statement instead of manual resource management strategy