The lines are whitespace separated, simply loop over the file, and use .split()
:
with open('dist.all.last') as inputfile:
names = [line.split()[0] for line in inputfile if line.strip()]
If you need to pick one name at random from that, you could use:
import random
with open('dist.all.last') as inputfile:
name = None
for i, line in enumerate(inputfile):
r = random.randint(0, i)
if not r and line.strip():
name = line.split()[0]
which makes a selection without keeping more than one line at a time in memory.