there is no way to do this easily in VHDL. VHDL is not set up to do File io nicely other than text.
What file are you trying to read? For every file you can use the ENDFILE() function to see if you have reached the end of a file:
eg.
Code:
while not ENDFILE(my_file) loop
readline(file, inline);
...etc
end loop;
You could use this loop method to count the number of lines in a text file, or if you are using modelsim you can do this with bytes in a binary file, but its not very neat.
Otherwise, I suggest you make sure all your files are the same length before you try and read them.