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;