added w and r for binary mode