         writerInput.requestMediaDataWhenReady(on: queue, using: {
             var processing = true // safety flag to prevent runaway loops if errors
 
-            while writerInput.isReadyForMoreMediaData && processing {
+            while writerInput.isReadyForMoreMediaData, processing {
                 if reader.status == .reading,
                     let buffer = readerOutput.copyNextSampleBuffer() {
                     writerInput.append(buffer)

        }

        // Create destination file
        error = ExtAudioFileCreateWithURL(
            outputURL as CFURL,
            format,
            &dstFormat,
            nil,
            AudioFileFlags.eraseFile.rawValue, // overwrite old file if present
            &destinationFile)

        if error != noErr {
            completionHandler?(createError(message: "Unable to create output file."))

        var outputBytesPerFrame = outputBitRate * outputChannels / 8
        var outputBytesPerPacket = options?.bitDepth == nil ? srcFormat.mBytesPerPacket : outputBytesPerFrame

        // in the input file this indicates a compressed format such as mp3
        if outputBitRate == 0 {
            outputBitRate = 16
            outputBytesPerPacket = 2 * outputChannels
