generic file read implemented.

much input validation required.