readn/writen improved