simple file manipulation and computation in Python