trying to write a readline-type function to get only printable chars