Working with local Data

Hi, i’m trying to use the new methods exposed in the FileReference class by flash player ten, as such I want the user to select a file, load it, pass it to a byteArray and then chunk it up and edit piece by piece.I have gotten everything to work except the whole chunking thing. In the example below it shows me trying to copy the byteArray, but for some reason it is giving me weird End of file errors, any ideas? I’ve been pulling my hair out over this for the last 3 days.

stage.addEventListener(MouseEvent.CLICK, clickhandler);

var fileref:FileReference = new FileReference();
fileref.addEventListener(Event.SELECT, onselect);
fileref.addEventListener(Event.COMPLETE, complete);

function clickhandler(evt:MouseEvent):void{
	fileref.browse();
}
function onselect(evt:Event):void{
	fileref.load();
}
function complete(evt:Event):void{
	var ba:ByteArray = new ByteArray();
	ba.readBytes(fileref.data,0,fileref.data.bytesAvailable);
}