1 open(IN,"<crypt.ind"); 2 open(OUT,">crypt.ind.tmp"); 3 $a = <IN>; 4 print OUT "$a\n\\addcontentsline{toc}{chapter}{Index}\n"; 5 while (<IN>) { 6 print OUT $_; 7 } 8 close OUT; 9 close IN; 10 system("mv -f crypt.ind.tmp crypt.ind"); 11 12