fix error handling in mkfile

@lennartcl