I've been working on a PowerShell script using Streamreader (and StreamWriter) to parse a large file into smaller reports. While doing some searching around on the best way to put this thing together, I've found there are two methods largely used to read content to the end of the file.
1 - while ($reader.Peek() -ge 0) { $line = $reader.Readline() ... }
2 - while (($line = $read.ReadLine()) -ne $null) { do stuff ... }
From the documentation, it looks like Peek will read the next value, but not change the position of the reader. It looks like ReadLine will essentially do the same, but read a whole string/line. I feel like this is a "no-duh" question - is it really more efficient to actually peek at a value before reading the line, or is it just an extra step before assigning the reader to a variable?
Thank you in advance!