Most of the time, instead of sending file names to be used, you should send your loaded arrays. Don't forget the size of the arrays. That should also be sent.
Also, you won't need to step through the array, counting to find the i'th item (like you had to for the file). You need only access it.