diff --git a/options_element.inc b/options_element.inc
index 3b6be1a..f943d00 100644
--- a/options_element.inc
+++ b/options_element.inc
@@ -392,6 +392,11 @@ function _form_options_from_text($text, $key_type, $flat = FALSE, &$duplicates =
   $options = array();
   $new_key = 0;
   foreach ($items as $item) {
+    if (is_int($item['key'] * 1)) {
+      $new_key = max($item['key'], $new_key);
+    }
+  }
+  foreach ($items as $item) {
     // Assign a key if needed.
     if ($key_type == 'none') {
       $item['key'] = $new_key++;
