exercise from Learnig Python the Hard Way about file operation