moved creation of file to after return calculation