open my $fhi, '<', 'C:\shekhar_Axestrack_Intern\WindowCreation\ListOfIpAdress.txt', or die "Could not open file $!"; while (my $line = <$fhi>) { ## Doing some operation using $fhi in read mode if($Time >'33') { $fhi->autoflush; #flush the line if time is greater than 33 hours, whereas all other lines which do not folow the condition are still present in file. } } close $fhi; #### open my $fhi, '<', 'C:\shekhar_Axestrack_Intern\WindowCreation\ListOfIpAdress.txt', or die "Could not open file $!"; open my $fho, '>', 'C:\shekhar_Axestrack_Intern\WindowCreation\ListOfIpAdress.txt', or die "Could not open file $!"; while (my $line = <$fhi>) { //Here i write the code to get the time from text file in ech line and below i check in if condition if that exceed 34 hours then flush that line if($Time >'34') { $fhi->autoflush; } print $fho; } close $fhi;