Replaced file r/w with InputStream