Validated tofile/fromfile