in reply to taking file from user

"all I want is that if the user for the first time gives wrong file name which does not belong in a directory a message should be displayed"

How do you tell if a file blongs in a direcetory or not? Likely you want to look at -X, I suspect you want to know if the file exists, is a normal file, is readable etc.