Reading the last index of openedFiles, because it was causing an error when the user did not upload correctly the file the first time. The files are added without clearing and I was checking the old entry