added support for passing file like object