Made a file preparing function