added comment, fixed fclose to before the return