Don't rely on keys to be ordered.
Make sure file gets closed.
Use new-style print function.