Corrected print method for linked list