Changed file handling from text to datastream