in reply to Reading and incrementing an integer

You probably want replace old number with new one

sub write_hits { my $hit_count = &read_hits($_[0]); open (HITSW, '>', "$_[0]"); $hit_count++; print HITSW $hit_count; close (HITSW); }