close then file ends and pass file as argument