pass file stream to function
update documentation