file pointer bug fix