while read a; do
  if [ $a -eq 42 ]; then
    exit
  else
    echo $a
  fi
done