how to grab some information from log file to make a new file

The number (5001) may vary depending on how long you run the simulation. If the simulation time does not change, open a text editor and read the number of rows you want to read and use that number instead of 5001.