Checks if list is empty before calling traverse list. for empty list it exits with an error message