ram's answers

A longer solution but good filehandle practice, including closing the handle.