f.close() is redundant in this case