Fix writeTextFile synchronous operation