<p>I'm writing a simple program that's going to parse a logfile of a packet dump from wireshark into a more readable form. I'm doing this with python.</p>

<p>Currently I'm stuck on this part:</p>

<pre><code>for i in range(len(linelist)):
if '### SERVER' in linelist[i]:
    #do server parsing stuff

    packet = linelist[i:find("\n\n", i, len(linelist))]
</code></pre>

<p>linelist is a list created using the readlines() method, so every line in the file is an element in the list. I'm iterating through it for all occurances of "### SERVER", then grabbing all lines after it until the next empty line(which signifies the end of the packet). I must be doing something wrong, because not only is find() not working, but I have a feeling there's a better way to grab everything between ### SERVER and the next occurance of a blank line.</p>

<p>Any ideas?</p>

Looking at the
file.readlines()
doc:
file.readlines([sizehint])
Read until EOF using readline() and return a list containing the lines thus read. If the optional sizehint argument is present, instead of reading up to EOF, whole lines totalling approximately sizehint bytes (possibly after rounding up to an internal buffer size) are read. Objects implementing a file-like interface may choose to ignore sizehint if it cannot be implemented, or cannot be implemented efficiently.
and the
file.readline()
doc:
file.readline([size])
Read one entire line from the file. A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line). [6] If the size argument is present and non-negative, it is a maximum byte count (including the trailing newline) and an incomplete line may be returned. An empty string is returned only when EOF is encountered immediately.
```
A trailing newline character is kept in the string
```
- means that each line in
```
linelist
```
will contain at most
one
newline. That is why you cannot find a
```
"\n\n"
```
substring in any of the lines - look for
a whole blank line
(or an empty one at EOF):
```
```
if myline in ("\n", ""):
    handle_empty_line()
```
```
Note: I tried to explain
```
find
```
behavior, but a pythonic solution looks very different from your code snippet.