read amd write for a file using wait and notify