you could of course test out each filenumbers if they're open but i recommend you should use FreeFile function to return the next free filenumber when you open a new file
Code:
ff1=freefile
open file for input as ff1
ff2=freefile
open file for output as ff1
.
.