Check for sensor at start of each loop

Unplugging the sensor while the program was running would cause an
ungraceful crash when the program attempted to read from the sensor
during the next loop. This should reduce the chance of that
happening.