Made write params a separate method

And fixed the ignored directory parameter