Adding infinite loop limitation implementing take() function in Stream class