You also have to make sure that the files are closed. If there's a return statement before the close, like inside an if or a loop, the file won't be closed. Same goes with sockets, which can be more problematic because they may be asynchronous, so tracking down the closing bit and making sure it's a...