Fixed a bug where a race condition was created on write, due to lack of proper
file closing on the string index file.