These two while loops look identical except for the length they check.  Can you combine them or turn them into a method?