added -r option to open a file readonly