Use the `matches` crate rather than re-defining multiple copies of it.
Use `while let` instead of `loop` + `match` + `break`.