diff --git a/scripts/reformat.pl b/scripts/reformat.pl
index 0c46c66..3b04399 100755
--- a/scripts/reformat.pl
+++ b/scripts/reformat.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#! /usr/bin/env perl
 
 # reformat.pl 
 # Reformat a multiple alignment file
@@ -33,7 +33,7 @@ my $numres=100;             # number of residues per line
 my $desclen=1000;           # maximum number of characters in nameline
 my $ARGC=scalar(@ARGV);
 if ($ARGC<2) {
-    die("
+    print("
 reformat.pl from HHsuite3
 Read a multiple alignment in one format and write it in another format
 Usage: reformat.pl [informat] [outformat] infile outfile [options] 
@@ -85,6 +85,7 @@ Examples: reformat.pl 1hjra.a3m 1hjra.a2m
           reformat.pl test.a3m test.fas -num -r 90
           reformat.pl fas sto '*.fasta' .stockholm
 \n");
+exit 0;
 #  clu:  clustal format (hmmer output)
 #  sel:  Selex format
 #  phy:  Phylip format
@@ -168,7 +169,7 @@ if ($options=~s/(\S+)\s*$//) {
 	elsif ($outformat eq "afas")  {$outformat="fas";}
 	elsif ($outformat eq "afasta") {$outformat="fas";}
     } else {
-	print ("Using FASTA output format: '$options'\n"); $outformat="fas";
+	print STDERR "Using FASTA output format: '$options'\n"; $outformat="fas";
     }
 }
 if ($options=~s/(\S+)\s*$//) {
@@ -180,7 +181,7 @@ if ($options=~s/(\S+)\s*$//) {
 	elsif ($informat eq "fa")    {$informat="fas";}
 	elsif ($informat eq "fasta") {$informat="fas";}
     } else {
-	print ("Using FASTA input format: '$options'\n"); $informat="fas";
+	print STDERR "Using FASTA input format: '$options'\n"; $informat = "fas";
     }
 }
 
@@ -188,7 +189,7 @@ if ($options=~s/(\S+)\s*$//) {
 # Warn if unknown options found
 if ($options!~/^\s*$/) {
     $options=~s/^\s*(.*?)\s*$/$1/g; 
-    print("\nWARNING: unknown options '$options'\n");
+    print STDERR "\nWARNING: unknown options '$options'\n";
 }
 
 # Check if input and output formats are valid
@@ -210,20 +211,20 @@ if ($infile=~/\*/ || $outfile=~/^\./) # if infile contains '*' or outfile is jus
     $outfile=~/.*\.(\S*)$/;
     my $outext=$1;
     my @infiles=glob($infile);
-    printf("%i files to reformat\n",scalar(@infiles));
+    printf STDERR "%i files to reformat\n", scalar(@infiles);
     foreach $infile (@infiles) 
     {
 	if ($infile!~/(\S+)\.\S+/) {$infile=~/(\S+)/}
 	$outfile="$1.$outext";
 	if ($update && -e $outfile) {next;}
-	if ($v>=3) {print("Reformatting $infile from $informat to $outformat ...\n");} 
+	if ($v>=3) {print STDERR "Reformatting $infile from $informat to $outformat ...\n";} 
 	&reformat($infile,$outfile);
     }
     exit 0;
 }
 else
 {
-    if ($v>=3) {print("Reformatting $infile from $informat to $outformat ...\n");} 
+    if ($v>=3) {print STDERR "Reformatting $infile from $informat to $outformat ...\n";} 
     &reformat($infile,$outfile); 
     exit 0;
 }
@@ -367,7 +368,7 @@ sub reformat()
 		} 
 		$name=$1;
 		$residues=$2;
-		print("WARNING: Found no space between name and residues in $infile, line $.: '$line'\n");
+		print STDERR "WARNING: Found no space between name and residues in $infile, line $.: '$line'\n";
 	    } else {
 		if ($noss && ($line=~/^aa_/ || $line=~/^ss_/ || $line=~/^sa_/)) {next;} # do not read in >ss_ and >aa_ sequences
 		if ($line=~/^aa_/ || $line=~/^sa_/) {next;}     # do not read in >ss_ and >aa_ sequences
@@ -388,7 +389,7 @@ sub reformat()
 	    } else {
 		$seqs[$k].=$residues;
 		if ($names[$k] ne $name) {
-		    print("WARNING: name of sequence $k in block 1 ($names[$k]) is not the same as in block $block ($name) in $infile\n");
+			print STDERR "WARNING: name of sequence $k in block 1 ($names[$k]) is not the same as in block $block ($name) in $infile\n";
 		}
 	    }
 #	    printf("%3i %3i %-16.16s %s\n",$block,$k,$names[$k],$seqs[$k]);
@@ -439,7 +440,7 @@ sub reformat()
 	    } else {
 		$seqs[$k].=$residues;
 		if ($names[$k] ne $name) {
-		    print("WARNING: name of sequence $k in block 1 ($names[$k]) is not the same as in block $block ($name) in $infile\n");
+		    print STDERR "WARNING: name of sequence $k in block 1 ($names[$k]) is not the same as in block $block ($name) in $infile\n";
 		}
 	    }
 #	    printf("%3i %3i %-16.16s %s\n",$block,$k,$names[$k],$seqs[$k]);
@@ -480,7 +481,7 @@ sub reformat()
     # Insertion of '.' only needed for a3m if: NOT -r option  OR  -M first  OR  -M <int> option
     if ($informat eq "a3m" && (!$remove_inserts || $matchmode)) 
     {
-	print("inserting gaps...\n");
+	print STDERR "inserting gaps...\n";
 	my @len_ins;   # $len_ins[$j] will count the maximum number of inserted residues after match state $i.
 	my $j;       # counts match states
 	my @inserts; # $inserts[$j] contains the insert (in small case) of sequence $i after the $j'th match state
@@ -663,7 +664,7 @@ sub reformat()
     my $nin=$n;
     for ($k=0; $k<$n; $k++) {
 	if (($seqs[$k]=~tr/a-zA-Z0-9/a-zA-Z0-9/==0)) {
-	    if ($v>=2) {print("Sequence contains only gaps and is removed: $names[$k]\n");}
+	    if ($v>=2) {print STDERR "Sequence contains only gaps and is removed: $names[$k]\n";}
 	    splice(@seqs,$k,1);
 	    splice(@names,$k,1);
 	    $k--; $n--;
@@ -699,10 +700,10 @@ sub reformat()
 	my $len=length($seqs[0]);
 	for($k=1; $k<$n; $k++) {
   	    if (length($seqs[$k])!=$len) {
-		printf("\nError: Sequences in $infile do not all have same length, e.g. >%-.20s  (len=%i)  and  >%-.20s  (len=%i)\n",
-		       $names[0],$len,$names[$k],length($seqs[$k]));
+		printf STDERR "\nError: Sequences in $infile do not all have same length, e.g. >%-.20s  (len=%i)  and  >%-.20s  (len=%i)\n",
+		       $names[0],$len,$names[$k],length($seqs[$k]);
 		if ($v>=3) {
-		    printf("%.20s %s\n%.20s %s\n\n",$names[0],$seqs[0],$names[$k],$seqs[$k]);
+		    printf STDERR "\nError: Sequences in $infile do not all have same length, e.g. >%-.20s  (len=%i)  and  >%-.20s  (len=%i)\n",
 		}
 		exit 1;
 	    }
@@ -813,10 +814,10 @@ sub reformat()
     
     close OUTFILE;
     if ($v>=2) {
-	if ($nin==1) {print("Reformatted $infile with 1 sequence from $informat to $outformat and written to file $outfile\n");}
+	if ($nin==1) {print STDERR "Reformatted $infile with 1 sequence from $informat to $outformat and written to file $outfile\n";}
 	else {
-	    if (!$nin==$n) {printf("Removed %i sequences which contained no residues\n",$nin-$n); }
-	    print("Reformatted $infile with $n sequences from $informat to $outformat and written to file $outfile\n");
+	    if (!$nin==$n) {printf STDERR "Removed %i sequences which contained no residues\n", $nin - $n;}
+	    print STDERR "Reformatted $infile with $n sequences from $informat to $outformat and written to file $outfile\n";
 	}
     }
     
