Fixes leaking of resources when seeking through a file.