Fixed overwrite flag

Change-Id: I3f46b02f043f8e83f82dd8929a4921f3a778a93e
diff --git a/script/korapxml2krill b/script/korapxml2krill
index 0efdd3a..cde5e37 100644
--- a/script/korapxml2krill
+++ b/script/korapxml2krill
@@ -138,6 +138,7 @@
 sub get_file_name ($) {
   my $i = $input[0];
   my $file = shift;
+  $file =~ s!^/?tmp/[^/]+!!;
   $file =~ s/^?\/?$i//;
   $file =~ tr/\//-/;
   $file =~ s{^-+}{};
@@ -477,9 +478,14 @@
       my ($prefix, $corpus, $doc, $text) = $archive->split_path($dirs[$i]);
 
       unless ($overwrite) {
+
+	# This is not correct!!
 	my $filename = catfile(
 	  $output,
-	  get_file_name(catdir($doc, $text)) . '.json' . ($gzip ? '.gz' : '')
+	  get_file_name(
+	    catfile($corpus, $doc, $text)
+	      . '.json' . ($gzip ? '.gz' : '')
+	    )
 	);
 
 	if (-e $filename) {