Fix bug 2717, bad file pointer