Change file modes and make Problem 24 more Pythony