diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/modification/KeyRingEditor.java b/pgpainless-core/src/main/java/org/pgpainless/key/modification/KeyRingEditor.java index 0626744c..f1299b7e 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/modification/KeyRingEditor.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/modification/KeyRingEditor.java @@ -91,7 +91,7 @@ public class KeyRingEditor implements KeyRingEditorInterface { Iterator secretKeyIterator = secretKeyRing.getSecretKeys(); boolean found = false; - while (secretKeyIterator.hasNext()) { + while (!found && secretKeyIterator.hasNext()) { PGPSecretKey secretKey = secretKeyIterator.next(); if (secretKey.getKeyID() == keyId) { found = true;