openfile funct fixed