Question: Trying to search for a string (email address) and print the line it is found in within a 1.66 gig .dump file(ashley madison). If I change print (line) to print ('true'), i get true returned, so i know it is reading the file, but when I try to print the line, python crashes with no error. Please help. python 3.4 on windows vista (rather than using a database and importing, I'm using this as a learning exercize for python)

```
import os

with open('aminno_member_email.dump', 'r', errors = 'ignore')as searchfile:
    for line in searchfile:
        if 'email@address.com' in line:
            #print ('true')
            print (line)

```

Answer: 
As I suspected, each line of that file is very long (to the tune of nearly a million characters, as you found). Most consoles are not set up to handle that sort of thing, so writing that line to a text file is your best bet. You can then open the file in a text editor or word processor and use its search function to locate areas of interest.

To display your search string with some characters of surrounding text, you can use a regular expression.

```
import re
...
# replace this:
'''
    if 'email@address.com' in line:
        #print ('true')
        print (line)
'''
# with this:
    print(*re.findall(r'(.{0,10}email@address\.com.{0,10})', line), sep='\n')

```

That will print each match with up to `10` characters before and after the search string, separated by a newline.

Example:

```
>>> print(*re.findall(r'(.{0,10}str.{0,10})', 'hello this is a string with text and it is very strong stuff'), sep='\n')
this is a string with t
t is very strong stuff

```
Open the file as stream instead and read from the stream instead of loading the entire file to RAM. Use [**io** from the Python standard library](https://docs.python.org/2/library/io.html).

```
with io.open('aminno_member_email.dump', 'r') as file:
    ...

```