Fix loop with multiple files

The random lookup would loop infinitely, if no files were
open. So check for that and check for number of files
done.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/filesetup.c b/filesetup.c
index e9dc72d..aad0720 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -523,6 +523,7 @@
 
 	if (td->io_ops->close_file)
 		td->io_ops->close_file(td, f);
+
 	td->nr_open_files--;
 	f->flags &= ~FIO_FILE_OPEN;
 }