script working with while loop