rename 'file' variable to 'fd', comment 'format' arg