     }
     
     func locationManager(manager: CLLocationManager, didUpdateLocations locations: [AnyObject]) {
+        exitAtTimeout = false
         let location = locations.first as! CLLocation
         
         if format.rangeOfString("%address") != nil {

    var once = false
    var verbose = false
    var format = "%latitude %longitude"
    
    func start() {
        self.locationManager.desiredAccuracy = kCLLocationAccuracyBest

            print("headingAvailable: \(CLLocationManager.headingAvailable())")
            print("regionMonitoringAvailable for CLRegion: \(CLLocationManager.isMonitoringAvailableForClass(CLRegion))")
        }
        let _ = NSTimer.scheduledTimerWithTimeInterval(10.0, target: self, selector: #selector(self.timeout), userInfo: nil, repeats: false)
        self.locationManager.startUpdatingLocation()
    }

    @objc func timeout() {
        if exitAtTimeout {
            print("Fetching location timed out. Exiting.")
            exit(1)
        }
    }
    
    func printFormattedLocation(location: CLLocation, address: String? = nil) {
