implemented while loop in read-command; there is segmentation fault