Great that you remembered to close the file :)
However, if an error occurred in between the opening and closing it could be left opened, take a look at File.open method with block, which auto-closes the file.