When input a value in a search box it shows all the events and all the values are displayed which are not in the file anymore. How to restrict events to show the latest results in a txt file? Or should I reindex the file?
"which are not in the file anymore"
Yes, this is what Splunk is about, a timebase search tool for events with a timestamp.
It doesn't know anything about what is in the log file now.
If you want to see the latest values, restrict the search time range.
if your log file is always the same format with fields (like a configuration file), and is erased and replaced by the new version, you could use the "dedup" command to retrieve the latest values for a given field.