Only write to port_file if it is not NULL.