f.read coming up empty

You can only read a file once. After that, the current read-position is at the end of the file.

If you add file1.seek(0) before you re-read it, you should be able to read the contents again. A better approach, however, is to read into a string the first time and then keep it in memory:

loc1 = '/council/council1'
file1 = open(loc1, 'r')
string1 = file1.read()
print string1

Leave a Comment