writing and readinng files fixed

all systems go, need error checking