Thanks for the pointer. Yes, it is a text file, but the mystery runs deeper: I later found that it works perfectly as written when I run it from IDLE or the Python shell, but it fails reliably when I run it from PyScripter 2.4.1 (an open source Python IDE)! So I suspect there's a PyScripter issue lurking in here. I'm next going to try the solution you propose - use only for legal offsets - and then retry it under both IDLE and PyScripter. Question: how do I use f.tell() to identify if an offset is legal or illegal?
Thanks in advance Thomas Philips -- http://mail.python.org/mailman/listinfo/python-list