Forgot to close file in write function