Tab fixes, add of write to file function