writeFile added, return messages rearranged