Writes SQL file