user: defer file.Close after checking for errors