Hi Priya,
Encapsule your script with a "loop_while" function.
The while condition should be something like following...
Loop while $L_FILECOUNT IS NOT NULL
The idea for the loop is, that while there are files in the folder, the filecount will not be NULL - and while it is not NULL it shall loop the "wait_for_file" function.
I'm sure you understand the idea!
Regards