diff --git a/src/lib/Guiguts/HTMLConvert.pm b/src/lib/Guiguts/HTMLConvert.pm
index 77180264..bc6d4340 100644
--- a/src/lib/Guiguts/HTMLConvert.pm
+++ b/src/lib/Guiguts/HTMLConvert.pm
@@ -3289,8 +3289,11 @@ sub autoindex {
my $first = 1;
my $indent = 0;
+ my $endstep = $textwindow->index('end');
+ $endstep =~ s/\..*//;
while ( $textwindow->get( "$step.0", "$step.end" ) eq '' ) {
$step++;
+ return if $step >= $endstep;
}
while ( $step <= $ler ) {
my $selection = $textwindow->get( "$step.0", "$step.end" );