rewrite FileInput and FileOutput